Thank you for the links. I've copied and pasted the code above for you
to access here:

http://78.40.35.58/map.html

On Dec 7, 11:14 am, Marcelo <[email protected]> wrote:
> On Dec 7, 11:49 am, ca8msm <[email protected]> wrote:
>
> > Hi,
>
> > I'm attempting to perform a local search and then show the results in
> > multiple markers on the map. Here is my code:
>
> and here are the group's posting 
> guidelines:http://groups.google.com/group/Google-Maps-API/web/suggested-posting-...http://groups.google.com/group/Google-Maps-API/web/why-including-a-li...
>
> --
> Marcelo -http://maps.forum.nu
> --
>
>
>
> > <html>
> > <head>
> > <title>Maps</title>
> > <script type="text/javascript" src="http://ajax.googleapis.com/ajax/
> > libs/jquery/1.3.2/jquery.min.js"></script>
> > <script src="http://maps.google.com/maps?
> > file=api&v=2&key=ABQIAAAAXOgIDJVlQPIrTHqlIhXImRSM9HAn8DP4x_AGPTbz1GFHpAOl3BShLj_XoQwnoMVvbpHEp519BY_arA"
> > type="text/javascript"></script>
> > <script src="http://www.google.com/uds/api?
> > file=uds.js&v=1.0&key=ABQIAAAAXOgIDJVlQPIrTHqlIhXImRSM9HAn8DP4x_AGPTbz1GFHpAOl3BShLj_XoQwnoMVvbpHEp519BY_arA"
> > type="text/javascript"></script>
> > <script src="gmap.js" type="text/javascript"></script>
> > <script type="text/javascript">$(window).load(function(){
> > usePointFromPostcode('PE19 7JH', placeMarkerAtPoint, '1');
> > usePointFromPostcode('E1 7HJ', placeMarkerAtPoint, '2');
> > usePointFromPostcode('LS1 5PS', placeMarkerAtPoint, '3');
> > usePointFromPostcode('PE19 8JQ', placeMarkerAtPoint, '4');
> > usePointFromPostcode('PE19 8JQ', placeMarkerAtPoint, '5');
> > usePointFromPostcode('B1 2RA', placeMarkerAtPoint, '6');
> > usePointFromPostcode('B15 1AY', placeMarkerAtPoint, '7');
> > usePointFromPostcode('SR1 1XS', placeMarkerAtPoint, '8');
> > usePointFromPostcode('DL1 4SL', placeMarkerAtPoint, '9');
> > usePointFromPostcode('SR1 1XS', placeMarkerAtPoint, '10');
> > usePointFromPostcode('SY2 5HG', placeMarkerAtPoint, '11');
> > usePointFromPostcode('SY1 1SP', placeMarkerAtPoint, '12');
> > usePointFromPostcode('SY1 1QH', placeMarkerAtPoint, '13');
> > usePointFromPostcode('SY2 5HG', placeMarkerAtPoint, '14');
> > usePointFromPostcode('SY2 5AT', placeMarkerAtPoint, '15');
> > usePointFromPostcode('DN15 7RG', placeMarkerAtPoint, '16');
> > usePointFromPostcode('DN16 1RA', placeMarkerAtPoint, '17');
> > usePointFromPostcode('PO1 2HW', placeMarkerAtPoint, '18');
> > usePointFromPostcode('P05 3PS', placeMarkerAtPoint, '19');
> > usePointFromPostcode('SR1 1XS', placeMarkerAtPoint, '20');});
>
> > </script>
>
> >   </head>
>
> >   <body>
> >     <div id="map" style="width: 500px; height: 300px"></div>
> >   </body>
> > </html>
>
> > and my javascript file:
>
> > var map;
> > var localSearch = new GlocalSearch();
>
> > var icon = new GIcon();
> > icon.image = "http://www.google.com/mapfiles/marker.png";;
> > icon.shadow = "http://www.google.com/mapfiles/shadow50.png";;
> > icon.iconSize = new GSize(20, 34);
> > icon.shadowSize = new GSize(37, 34);
> > icon.iconAnchor = new GPoint(10, 34);
>
> > function usePointFromPostcode(postcode, callbackFunction, message) {
>
> >         localSearch.setSearchCompleteCallback(null,
> >                 function() {
>
> >                         if (localSearch.results[0])
> >                         {
> >                                 var resultLat = localSearch.results[0].lat;
> >                                 var resultLng = localSearch.results[0].lng;
> >                                 var point = new 
> > GLatLng(resultLat,resultLng);
> >                                 callbackFunction(point, message);
> >                         }//else{
> > //                              alert("Postcode not found!");
> > //                      }
> >                 });
>
> >         localSearch.execute(postcode + ", UK");
>
> > }
>
> > function placeMarkerAtPoint(point, message)
> > {
> >         var marker = createMarker(point,message)
> >         map.addOverlay(marker);
>
> > }
>
> > function createMarker(point,html) {
> > var marker = new GMarker(point);
> > GEvent.addListener(marker, "click", function() {
> >   marker.openInfoWindowHtml(html);
>
> > });
> > return marker;
> > }
>
> > function setCenterToPoint(point)
> > {
> >         map.setCenter(point, 17);
>
> > }
>
> > function showPointLatLng(point)
> > {
> >         alert("Latitude: " + point.lat() + "\nLongitude: " + point.lng());
>
> > }
>
> > function mapLoad() {
> >         if (GBrowserIsCompatible()) {
> >                 map = new GMap2(document.getElementById("map"));
>
> >                 map.addControl(new GLargeMapControl());
> >                 map.addControl(new GMapTypeControl());
> >                 map.setCenter(new GLatLng(54.622978,-2.592773), 6, 
> > G_HYBRID_MAP);
> >         }
>
> > }
>
> > function addLoadEvent(func) {
> >   var oldonload = window.onload;
> >   if (typeof window.onload != 'function') {
> >     window.onload = func;
> >   } else {
> >     window.onload = function() {
> >       oldonload();
> >       func();
> >     }
> >   }
>
> > }
>
> > function addUnLoadEvent(func) {
> >         var oldonunload = window.onunload;
> >         if (typeof window.onunload != 'function') {
> >           window.onunload = func;
> >         } else {
> >           window.onunload = function() {
> >             oldonunload();
> >             func();
> >           }
> >         }
>
> > }
>
> > addLoadEvent(mapLoad);
> > addUnLoadEvent(GUnload);
>
> > The searches are working correctly, however, each openInfoWindowHtml
> > is showing the same text. I'm sure this is because of the asynchronous
> > calls for the search and I'm sure it's also the same pitfall that Mike
> > lists in point 3 here:http://econym.org.uk/gmap/basic1.htm
>
> > My problem is whilst I understand why this can happen, I'm unsure as
> > to how to fix it. I'd hoped that by using the "createMarker" function
> > that I wouldn't run into this issue but obviously there is something
> > I'm missing.
>
> > Can anyone show me what I need to change in my code above to show the
> > correct messages?
>
> > Thanks,
> > Mark

--

You received this message because you are subscribed to the Google Groups 
"Google Maps API" 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.


Reply via email to