On Oct 12, 4:09 pm, BenB <[email protected]>
wrote:
> Thanks Andrew
>
> I tried adding the complete line "  var marker = new GMarker(point,
> {icon:parkingIcon}); " to each of the entries,

OK. There's an issue with re-using variable names. My example was
talking about the createMarker function.

 function createMarker(point,html,iconToUse) {
   var marker = new GMarker(point,{icon:iconToUse});
   GEvent.addListener(marker, "click", function() {
   marker.openInfoWindowHtml(html);
   });
   return marker;
 }

and then where you set up and add each marker:

  var point = new GLatLng(52.055278, 1.154702);
  var marker = createMarker(point,'Turret Lane Parking',parkingIcon)
  map.addOverlay(marker);

Note that although you use two variables called "marker", one outside
the function and one inside, they are not the same. In fact using the
function to get the right infoWindow text relies on them not being the
same.

Outside the function [second code snippet here], the code passes three
parameters to a function called createMarker. That creates a new
GMarker and refers to it by a name "marker". Because of the "var"
keyword inside the function, it's local to the function. At the end of
the function, it returns the object it knows as "marker" back to where
the function was called.

The code outside the function receives the object and assigns it to a
variable which it's called "marker". It then adds that object to the
map.

Andrew
--~--~---------~--~----~------------~-------~--~----~
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