On Nov 30, 1:26 am, Medma <[email protected]> wrote: > Hi There ! > I'm new in google maps api > I have build a function for plotting several address onto the map which > comes from db > > This is the loop pro plotting multiple address onto the map > > var geocoder=new GClientGeocoder; > for(i=0;i<address.length;i++){ > geocoder.getLatLng(address[i],function(point){ > map.addControl(new GSmallMapControl()); > map.addControl(new GMapTypeControl()); > if (point){ > map.setCenter(point, 13); > map.addOverlay(createmarker(point)); > > } > }); > } > > the createmarker function as > > function createmarker(p){ > var m = l-1; > var num = runorder[m]; > > var icon = new GIcon(); > icon.image > = 'http://gmaps-samples.googlecode.com/svn/trunk/markers/circular/greenc... > icon.iconSize = new GSize(25, 25); > icon.iconAnchor = new GPoint(13, 12); > icon.infoWindowAnchor = new GPoint(25, 7); > > opts = { > "icon": icon, > "clickable": true, > "labelText": num, > "labelOffset": new GSize(-6, -10) > > }; > > var marker = new LabeledMarker(p, opts); > GEvent.addListener(marker, "click", function() { > marker.openInfoWindowHtml(displayadd[m]);}); > > labeledmarkers[l-1] = marker; > l=l+1; > return marker; > > } > > the problem is this sometime it plot the 12 address and when i refresh > th page markers are changed and sometimes plots only 1 address no any > condition to plot the total address from my address[] array > > what to do is there i have mistaken?
Please read the posting guidelines, and post a link to your map that exhibits the problem, not code. The geocoder is asynchronous, subject to a quota and rate limiting. It is bad practice to geocode addresses everytime your map loads, geocode them once, off-line, and use the coordinates to display the markers on the map. This article may help (it was written for the v3 API, but the considerations are similar): http://code.google.com/apis/maps/articles/geocodestrat.html -- Larry -- You received this message because you are subscribed to the Google Groups "Google Maps API V2" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-api?hl=en.
