02-07-2012 05:11 AM - last edited on 02-07-2012 05:21 AM
Hi all
i am trying to show multiple pin point (pin point should be dynamic means no of pin point will be based on city) on google map at the same time for one city ,and it should be dynamic means after changing the city pin point also should be changed .
for this i am using google map api for blackberry ,and accessing it through kml file but i am not getting the correct, so please reply me the details how to use it or any other way to use.
thanks in advance
Regard
Avinash
Solved! Go to Solution.
02-08-2012 01:19 AM
Hi avinash,
From which Os you are trying to do.If you are using 6.0 and above,you can trying using Javascript api for google.But below,it will wont work properly.
Trying using browserfield,in which send the html as string which contains javacript.
Regards
Rakesh shankar.P
02-08-2012 01:22 AM
While using kml ,you need to post kml file in some public servers accesible for google,so that you can use that kml ,pass it in google maps application in the device.I dont find this option the feasible one.
Regards
Rakesh shankar.P
02-08-2012 04:18 AM - last edited on 02-08-2012 04:19 AM
Hi
i am using os 5 and i am using this javascript code for browser field its working but i want to put latitude and longitude in a array to change dynamicaly please edit my code if possible or give any other idea
thanks
String HtmlContent="<!DOCTYPE html>"+"<html>"+"<head>"+
"<meta http-equiv='content-type' content='text/xhtml' charset='UTF-8' />"+
"<title>Google Maps Multiple Markers</title>"+
"<script src='http://maps.google.com/maps/api/js?sensor=false' type='text/javascript'>"+"</script>"+
"</head>"+
"<body>"+
"<div id='map' style='width: 420px; height: 320px;'>"+"</div>"+
"<script type='text/javascript'>"+
"var locations = [['lt'],['Coogee Beach', -33.923036, 151.259052, 5],['Cronulla Beach', -34.028249, 151.157507, 3],['Manly Beach', -33.80010128657071, 151.28747820854187, 2],['Maroubra Beach', -33.950198, 151.259302, 1]];"+
"var map = new google.maps.Map(document.getElementById('map'), {zoom: 2,center: new google.maps.LatLng(-33.92, 151.25), mapTypeId: google.maps.MapTypeId.ROADMAP});"+
"var infowindow = new google.maps.InfoWindow();"+
"var marker, i;"+
"for (i = 0; i < locations.length; i++) {marker = new google.maps.Marker({position: new google.maps.LatLng(locations[i][1], locations[i][2]),map: map});"+
"google.maps.event.addListener(marker, 'click', (function(marker, i) {return function() {infowindow.setContent(locations[i][0]);infowindow
"</script></body></html>";
BrowserFieldConfig _bfConfig = new BrowserFieldConfig();
_bfConfig.setProperty(BrowserFieldConfig.NAVIGATIO
_bfConfig.setProperty( BrowserFieldConfig.JAVASCRIPT_ENABLED, Boolean.TRUE );
_bfConfig.setProperty(BrowserFieldConfig.USER_AGEN
BrowserField myBrowserField = new BrowserField(_bfConfig);
// myBrowserField.requestContent("localhost://D:/Avin
myBrowserField.displayContent(HtmlContent, "http://localhost");
add(myBrowserField);
02-08-2012 04:26 AM
Hi
for kml i am using this code , and i am putting the file on the server but its not displaying the map please see my code and tel me the prosidure . if possible tel me the step.
thanks
int mh = CodeModuleManager.getModuleHandle("GoogleMaps");
// mh=0;
if (mh == 0) {
try {
throw new ApplicationManagerException(
"GoogleMaps isn't installed");
} catch (ApplicationManagerException e) {
System.out.println(e.getMessage());
}
}
String[] args = {"182.72.141.134/mobapp/test/map.kml"};
// MapsArguments ma = new MapsArguments
// (MapsArguments.ARG_KML, "182.72.141.134/mobapp/test/map.kml");
// Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, ma);
ApplicationDescriptor ad = CodeModuleManager.getApplicationDescriptors(mh)[0]
ApplicationDescriptor ad2 = new ApplicationDescriptor(ad, args);
try {
ApplicationManager.getApplicationManager()
.runApplication(ad2, true);
} catch (ApplicationManagerException e) {
System.out.println(e.getMessage());
}
}
map.kml
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<name>Bangalore</name>
<description>Bangalore - jaya nagar</description>
<Point>
<coordinates>12.9268153,77.5801317,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Bangalore - jp</name>
<description>Bangalore - jp nagar</description>
<Point>
<coordinates>12.9106074,77.5815116,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
02-08-2012 07:07 AM
Hi,
Try addding the multiple points in the script ,and if you find the any issues,Use firebug to find out the issue.
I used the same html doc that you are using.i got it successfully.
Regards
Rakesh Shankar.P
02-08-2012 07:18 AM
Hi thanks for replying
did you used this code as dynamicmeans to add on the basis of location the no of point should be changed (i mean can be use like an array of latitude and longitude)
if it is how please let me know.
var locations = [['lt'],['Coogee Beach', -33.923036, 151.259052, 5],['Cronulla Beach', -34.028249, 151.157507, 3],['Manly Beach', -33.80010128657071, 151.28747820854187, 2],['Maroubra Beach', -33.950198, 151.259302, 1]];
02-09-2012 01:17 AM
hi
Please reply if any body knows..........
02-09-2012 01:20 AM
Hi
please Reply me if any body knows.
02-09-2012 01:45 AM
package com.mapsdemo;
import java.util.Vector;
public class MultiplePoints {
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=false\" \r\n" +
" type=\"text/javascript\"></script>\r\n" +
"</head> \r\n" +
"<body>\r\n" +
" <div id=\"map\" style=\"width: 500px; height: 400px;\"></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: 10,";
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" +
" infowindow.open(map, marker);\r\n" +
" }\r\n" +
" })(marker, i));\r\n" +
" }\r\n" +
" </script>\r\n" +
"</body>\r\n" +
"</html>";
MultiplePoints(StringBuffer html,Vector waypoints,LocationObj center){
html.append(initial);
for(int i=0 ; i<waypoints.size(); i++){
LocationObj source = (LocationObj)waypoints.elementAt(i);
String point = "['"+source.getLabel()+"',"+source.getLatitude()+" ,"+ source.getLongitude()+","+i+"],";
System.out.println("Point is"+point);
html.append(point);
}
html.append(second);
centerPoint = " center: new google.maps.LatLng("+center.getLatitude()+","+cent er.getLongitude()+"),";
html.append(centerPoint);
html.append(finalpart);
System.out.println("Plot is"+html.toString());
}
}
Hi Avinash,it was my code for checking the multiple points.
Thanks
Rakesh Shankar.P