0

Google マップに場所を表示するために、BlackBerry アプリケーション (OS バージョン 6 および 7) 内で使用しているマークアップを以下に示します。

private String getHTMLText() {
    String HTMLText = null;
    HTMLText = "<script type=\"text/javascript\" src=\"http://maps.google.com/maps/api/js?sensor=false&libraries=drawing\"></script>" + 
               "<body onload=\"initialize();\" topmargin=\"0\" leftmargin=\"0\">" + 
               "<div id=\"map_canvas\" style=\"width:" + Display.getWidth() + "px; height:" + Display.getHeight() + "px;\">" + 
               "</body>" + 
               "<script type=\"text/javascript\">" + 
               "var Coordinates= [];" + 
               "var locations = [" + getLocatinText() + 
               "];" + 
               "var map = new google.maps.Map(document.getElementById('map_canvas'), {" + 
               "zoom: " + iZoom + "," +
               "center: new google.maps.LatLng" + getCenterLocationText() + "," + 
               "mapTypeId: google.maps.MapTypeId.ROADMAP" + 
               "});" + 
               "var marker, i;" + 
               "marker = new google.maps.Marker({position: new google.maps.LatLng" + getCenterLocationText() + 
               ", map: map,icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|ff0084|ffffff'});" + 
               "for (i = 0; i < 1; i++) {" + 
               "marker = new google.maps.Marker({" + 
               "position: new google.maps.LatLng(locations[i][0], locations[i][1])," + 
               "map: map" + 
               "});" + 
               "Coordinates.push( new google.maps.LatLng(locations[i][0], locations[i][1]) );" + 
               "}" + 
               /*"var flightPath = new google.maps.Polyline({" + 
               "path: Coordinates," + 
               "strokeColor: \"#FF0000\"," + 
               "strokeOpacity: 0.7," + 
               "strokeWeight: 1" + 
               "});" +*/

               "</script>";

    return HTMLText;

}

すべての画像で、マップは正しく読み込まれますが、「申し訳ありませんが、ここには画像がありません」というテキストが上部に表示されます。

ただし、どのブラウザでも使用されている同じコードが正しく表示されます。

ここに画像の説明を入力

フィードバックをいただければ幸いです。

4

1 に答える 1

3

これを試して -

StringBuffer html;
                String initial = "<!DOCTYPE html>\r\n" +
                "<html> \r\n" +
                "<head> \r\n" +
                "  <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" /> \r\n" +
                "  <title>Google Maps Multiple Markers</title> \r\n" +
                "  <script src=\"http://maps.google.com/maps/api/js?sensor=true\" \r\n" +
                "          type=\"text/javascript\"></script>\r\n" +
                "</head> \r\n" +
                "<body>\r\n" +
                "  <div id=\"map\" style=\"width: 620px; height: 358px;\"></div>\r\n" +
                "\r\n" +
                "  <script type=\"text/javascript\">\r\n" +
                "    var locations = [";
        String second= " ];\r\n" +
                "\r\n" +
                "    var map = new google.maps.Map(document.getElementById('map'), {\r\n" +
                "      zoom: 8,";
        String centerPoint ="";
        String finalpart = " mapTypeId: google.maps.MapTypeId.ROADMAP\r\n" +
                "    });\r\n" +
                "\r\n" +
                "    var infowindow = new google.maps.InfoWindow();\r\n" +
                "\r\n" +
                "    var marker, i;\r\n" +
                "\r\n" +
                "    for (i = 0; i < locations.length; i++) {  \r\n" +
                "      marker = new google.maps.Marker({\r\n" +
                "        position: new google.maps.LatLng(locations[i][1], locations[i][2]),\r\n" +
                "        map: map\r\n" +
                "      });\r\n" +
                "\r\n" +
                "      google.maps.event.addListener(marker, 'click', (function(marker, i) {\r\n" +
                "        return function() {\r\n" +
                "          infowindow.setContent(locations[i][0]);\r\n" +
                "         \r\n" +
                "        }\r\n" +
                "      })(marker, i));\r\n" +
                "    }\r\n" +
                "  </script>\r\n" +
                "</body>\r\n" +
                "</html>";

            html=new StringBuffer();
            html.append(initial);
            String point = "['"+""+"',"+lattitude+","+longitude+","+""+"],";
            html.append(point);
            centerPoint = "  center: new google.maps.LatLng("+lattitude+","+longitude+"),";

               html.append(second);
               html.append(centerPoint);
               html.append(finalpart);
               //System.out.println("Plot is"+html.toString());
               BrowserFieldConfig _bfConfig = new BrowserFieldConfig();        
              _bfConfig.setProperty(BrowserFieldConfig.NAVIGATION_MODE,BrowserFieldConfig.NAVIGATION_MODE_POINTER);
              _bfConfig.setProperty( BrowserFieldConfig.JAVASCRIPT_ENABLED, Boolean.TRUE );
              _bfConfig.setProperty(BrowserFieldConfig.USER_AGENT, "MyApplication 1.0");
              BrowserField myBrowserField = new BrowserField(_bfConfig);
              myBrowserField.displayContent(html.toString(), "");
              add(myBrowserField);
于 2012-11-23T13:18:44.197 に答える