Trouble with markers

39 views
Skip to first unread message

gmapsNovice

unread,
Jul 21, 2011, 5:50:47 PM7/21/11
to google-map...@googlegroups.com
does anyone know a way to move your marker on the map?

The problem i'm having is that when the markers display on my map they are not centered or the marker does not seem to be centered to the location i want it to be. So what i want to do is to move the marker icon a little bit so it can be centered, basically i want to be able to move the marker icon on both the x and y axis that is on.

Anyone have any suggestions on how i can do this?

geoco...@gmail.com

unread,
Jul 21, 2011, 6:20:36 PM7/21/11
to Google Maps JavaScript API v3
Can't tell specifically what your problem is. Could you share a link
to your map that exhibits the problem?

Sounds like you mean your custom icons don't have the correct anchor.
http://code.google.com/apis/maps/documentation/javascript/reference.html#MarkerImage

-- Larry

gmapsNovice

unread,
Jul 21, 2011, 6:29:04 PM7/21/11
to google-map...@googlegroups.com
Yes that 's what i'm trying to do, i was able to and created a new icon:


var image = new google.maps.MarkerImage('http://www.worldarchitecturemap.org/images/tag_point.png',
new google.maps.Size(16,16),
new google.maps.Point(0,0),
new google.maps.Point(8,8));
i then added it to the marker as follows:

var marker = new google.maps.Marker({
position: point,
icon: image
});

That seems to work i just have to play with the anchor point now, the new problem that i'm having now is that i had to sets of icons for this one when the icon is inactive (when no infowindow is active/open) and another one when the user clicks on it to open the info window. The problem i' having now is that after i adjusted the anchor point on the main icon the other icons are rested to the old anchor points after the user clicks on a marker. 

So i did the same thing as above and created a new icon with the same options and made the code below:

function bindInfoWindow(marker, map, infoWindow, html) {
google.maps.event.addListener(marker, 'click', function() {
infoWindow.setContent(html);
infoWindow.open(map, marker);
marker.setIcon(activeImage);
       });
google.maps.event.addListener(infoWindow, 'content_changed', function(){
marker.setIcon(image);
});
google.maps.event.addListener(infoWindow, 'closeclick', function(){
marker.setIcon(image);
});
}

The problem with this is that the windows don't open now. Any one have any ideas?


geoco...@gmail.com

unread,
Jul 21, 2011, 6:30:55 PM7/21/11
to Google Maps JavaScript API v3
Did you miss my request for a link?
(I have to assume you didn't read the posting guidelines which also
asks for one...)

-- Larry

gmapsNovice

unread,
Jul 21, 2011, 6:33:01 PM7/21/11
to google-map...@googlegroups.com

gmapsNovice

unread,
Jul 21, 2011, 6:40:11 PM7/21/11
to google-map...@googlegroups.com
so google chrome is telling me that the variable image is undefined..

gmapsNovice

unread,
Jul 21, 2011, 6:44:55 PM7/21/11
to google-map...@googlegroups.com
Well...nvm it seems that i had placed the variables insdie the load function rather than outside..So my bad 
Reply all
Reply to author
Forward
0 new messages