Thanks , Andrew--
The first bit does indeed give the desired result, but in the end I do
want to have a custom icon, so I tried working with your second bit,
creating a new createCenterMarker().
But, I'm still getting the same results. I'm guessing it has to with
the "GEvent.addListener(marker, 'click', function() {" line, and the
'click' being called twice.
Here are my two fragments:
function createMarker(point, name, address, phone, moreinfo) {
var marker = new GMarker(point);
var html = '<b>' + name + '<br/>' + address + '</b> <br/>' +
phone + '<br />' + moreinfo;
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
function createCenterMarker (point, name) {
var marker = new GMarker(point);
var html = '<p class="Your Address:"> <br />' + name;
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
Thanks!
--Jason
On Fri, Feb 5, 2010 at 7:16 PM, Andrew Leach
<[email protected]> wrote:
> On Feb 6, 12:08 am, Jason Andreoni <[email protected]> wrote:
>>
>> Here's the code that Andrew suggested to get the marker on the map in
>> the first place, followed by my createMarker function that you
>> suggested modifying:
>>
>> map.addOverlay(createMarker(center,
>> document.getElementById('addressInput').value));
>> bounds.extend(center);
>> map.setCenter(bounds.getCenter(),
>> map.getBoundsZoomLevel(bounds));
>> });
>> }
>>
>> function createMarker(point, name, address, phone, moreinfo) {
>
> Note how many arguments the function needs (five) and how many you are
> supplying (two). Each of the missing arguments, address phone
> moreinfo, ends up as "undefined" within the function, because there is
> no value passed in. Perhaps I should have thought of that.
>
> You could change the addOverlay line to pass three additional empty
> strings into the function
> document.getElementById('addressInput').value,"","",""));
> or you could define and use a createCentreMarker() function which was
> almost the same as createMarker but only needed two arguments. That
> function could create a marker with a different icon, too.
>
> 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.
>
>
--
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.