I am using Drupal 6.x and am having issues using the Google Maps API when attempting to display a map with markers.
I searched for any sort of Google Map related thread/post but all i found were modules that used Google Maps.
I am simply trying to test out an example from the Google Maps API example code that uses markers. I view the source of the example, copy the code, and paste it into the page I am trying to create. However, for some reason it does not work. I have tested this out using a simple .html file and it works fine. However, within Drupal, it does not.
If I comment out the "for-loop" in the javascript below, the map will display (however without the markers, which is what the loop is for). Are there any limitations or settings that disable the use of some javascript calls or javascript itself? I really doubt this because Drupal itself uses a lot of Javascript. Perhaps I just do not understand javascript and the what the calls are referencing. Can anyone shed some light on this issue?
Here is the code:
function initialize() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map_canvas")); map.setCenter(new GLatLng(37.4419, -122.1419), 13); // Add 10 markers to the map at random locations var bounds = map.getBounds(); var southWest = bounds.getSouthWest(); var northEast = bounds.getNorthEast(); var lngSpan = northEast.lng() - southWest.lng(); var latSpan = northEast.lat() - southWest.lat(); for (var i = 0; i < 10; i++) { var latlng = new GLatLng(southWest.lat() + latSpan * Math.random(), southWest.lng() + lngSpan * Math.random()); map.addOverlay(new GMarker(latlng)); } } }
Comments
i am currently working on
i am currently working on some project based on gmap and drupal. i did not encounter any difficulty.
however, i am using drupal5. in ur case, i am not sure if it's caused by the jscrpit compress function in d6.
sry, i hv not try out d6 yet, cannot provide further help.
Experiencing same exact problem
its the for () statement that kills it. Did anybody report this yet?