Skip to content Skip to sidebar Skip to footer

Google Maps Image Marker Is Not Placing Correctly In The Sprite

I'm trying to use a sprite image for google map marker but it does not display. Here is the code I'm using function setMarkers(map, markers) { var google_image = new google.m

Solution 1:

There may be different issues for your problem. Few things to test before going into the issue-

Test your code without using a custom marker and see whether the marker gets displayed correctly. If that doesn't work your latlng values are wrong. If it works, then check whether your sprite image is accessible by your site(see the chrome or firebug console for errors). If there are no errors, then your position point may not be adjusted properly.

Also add map.setCenter(marker.getPosition()) after creating your marker so that it is shown in the viewing area.

Update- In the below line change your size and point parameters until you find the marker if the above issues aren't the problem.

var google_image = new google.maps.MarkerImage("http://www.mydomain.com/images/bodycss/pointer.png", new google.maps.Size(32, 32), new google.maps.Point(28, 32));

Solution 2:

At a first glance it's probably that you've set the coordinates wrong? LatLng's are usually expressed as something like: 54.621790812770513, -3.562549943618061.

The position you've specified (28, 32) is a point in Saudi Arabia and 100 miles from anywhere, unless this was your intention?

Also you're not centering the map on the point so it could be displaying (in Saudi Arabia) while your map is centered elsewhere?

Also please accept an answer should someone solve your issue (though I may not have). Only polite.

Post a Comment for "Google Maps Image Marker Is Not Placing Correctly In The Sprite"