Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/194.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何将Wikimapia与Google地图集成_Android_Google Maps - Fatal编程技术网

Android 如何将Wikimapia与Google地图集成

Android 如何将Wikimapia与Google地图集成,android,google-maps,Android,Google Maps,我正在开发一个Android应用程序,在这个应用程序中,我想从wikimapia获取最近的位置,并想在谷歌地图上用PinMarker显示这些位置 我还使用以下代码获取最近的医院位置,它使用Wikimapia获取最近的医院,但我无法将其与我的Google地图集成 String urlString = "http://api.wikimapia.org/?key="+key+" &function=place.getnearest&lat="+lastLoca

我正在开发一个Android应用程序,在这个应用程序中,我想从wikimapia获取最近的位置,并想在谷歌地图上用PinMarker显示这些位置

我还使用以下代码获取最近的医院位置,它使用Wikimapia获取最近的医院,但我无法将其与我的Google地图集成

String urlString = "http://api.wikimapia.org/?key="+key+"
            &function=place.getnearest&lat="+lastLocation.getLatitude()+
            "&lon="+lastLocation.getLongitude()+"&format=json&pack=&language=en&
            count=50&category="+category;
    try {

        URL url = new URL(urlString);

        URLConnection conn = url.openConnection();
        conn.setDoOutput(true);
        OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
        wr.flush();

        reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        StringBuilder sb = new StringBuilder();
        String line = null;

        while ((line = reader.readLine()) != null) {
            // Append server response in string
            sb.append(line + "");
        }

        String content = sb.toString();

        Logs.v(getLocalClassName(),
                "Places API InBackgroung, Contect = " + content);

        try {
            jObject = new JSONObject(content);

        } catch (Exception e) {
            Logs.e("Exception", e.toString());
        }
    }

    JSONArray arrayOfPlaces = jObject.getJSONArray("places");

    for (int i = 0; i < arrayOfPlaces.length(); i++) {

        final MarkerOptions markerOptions = new MarkerOptions();

        JSONObject jPlace = arrayOfPlaces.getJSONObject(i);

        if (!jPlace.isNull("title")) {
            place = jPlace.getString("title");
        }
        if (!jPlace.isNull("urlhtml")) {
            icon = jPlace.getString("urlhtml");
        }
        if (!jPlace.isNull("distance")) {
            distance = jPlace.getString("distance");
        }                       

        latitude = jPlace.getJSONObject("location").getString("lon");
        longitude = jPlace.getJSONObject("location").getString("lat");

        double lat = Double.parseDouble(latitude);
        double lng = Double.parseDouble(longitude);
        LatLng latLng = new LatLng(lat, lng);
        markerOptions.position(latLng);
        markerOptions.title(place);
        markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.hospital_building));
//Every value is getting through parsing, but pin markers are not displaying on the maps
//Secondly what is .setSnippet here??
        mMap.addMarker(markerOptions).setSnippet("");

    }
String url字符串=”http://api.wikimapia.org/?key=“+键+”
&function=place.getnearest&lat=“+lastLocation.getLatitude()+
“&lon=“+lastLocation.getLongitude()+”&format=json&pack=&language=en&
计数=50&category=“+category;
试一试{
URL=新URL(URL字符串);
URLConnection conn=url.openConnection();
连接设置输出(真);
OutputStreamWriter wr=新的OutputStreamWriter(conn.getOutputStream());
wr.flush();
reader=新的BufferedReader(新的InputStreamReader(conn.getInputStream());
StringBuilder sb=新的StringBuilder();
字符串行=null;
而((line=reader.readLine())!=null){
//在字符串中追加服务器响应
sb.追加(第+行“);
}
字符串内容=sb.toString();
Logs.v(getLocalClassName(),
“将API放入包装中,Contect=“+content”);
试一试{
jObject=新的JSONObject(内容);
}捕获(例外e){
Logs.e(“Exception”,e.toString());
}
}
JSONArray arrayOfPlaces=jObject.getJSONArray(“位置”);
对于(int i=0;i
您找到解决方案了吗?