Please let me know how to move customized google map marker above the latitude and longitude point?
Here is the JSBIN : Link, here i have used three object arrays, just used this link to understated the coding structure,
Please let me know where i have to insert "anchor" to position customized icon?
You can use the anchor property of the icon object and add any offset you need for the marker image.
var iconObj = {
url: '/path/to/icon.png', //path to icon image
origin: new google.maps.Point(0, 0), //position of the image within a sprite
anchor: new google.maps.Point(25, 25), //position at which to anchor an icon in correspondance to the position of the marker
};
var markerObj = new google.maps.Marker({
position: point,
map: map,
icon: iconObj
});
Update:
To answer your second question 'where do I put this exactly in my code' - you should put icon as an object in drivers array instead of a string.
Here's modified working version of your code
Related
I'm trying to put a google.maps.Marker object over (z-index positioning) an Infobubble object
but i am having no success.
Basically what i'm doing is assigning zIndex: n to the markerOptions object which I pass to the Marker constructor as follow:
var markerOptions = {
position: store.getLocation(),
title: store.getDetails().title,
icon: DEFAULT_MARKER,
anchorPoint: new google.maps.Point(20,5),
zIndex: 2
};
var marker = new google.maps.Marker(markerOptions);
I have already read this answer Google Maps v3 marker over infowindow but actually it has not got any votes. Can somebody tell me more about?
Thanks a lot
The problem, as commented by shaunhusain is the fixed pane where particular elements will be drawn.
It's correct that you need to use a custom overlay, but you must use it to draw the marker, not the infobubble.
The reason: infobubble is an implementation of a custom overlay, it will be drawn inside the floatPane. To put the marker on top the infobubble must be drawn into a pane with a zIndex equal or lower than the zIndex of the pane where the marker will be drawn.
But here comes the problem: all these panes do not receive mouse-events, you wouldn't be able to interact with the infobubble(select tabs, select text, click links, close the infobubble).
Therefore you must use a custom overlay to draw the markers, and you must put these overlays into the floatPane(it's the pane with the highest zIndex)
Anyone know the URL to this icon, and if you can change the color on the most recent version of Google Maps API ?
I'd like a blue/green icon like below!
EDIT -----------------------------------------
I've found the markers here:
Markers With Text
scale = 2
text = AB
psize = 16
Green Marker
Red Marker
Google Development: Markers
You can custom everything with the API of google map.
To have a different pointer, you must add a specific code and give him the link to the icon you want to assign, and its position.
Something like this for exemple:
var iconBase = 'https://maps.google.com/mapfiles/kml/shapes/';
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: iconBase + 'schools_maps.png'
});
Link to the documentation: https://developers.google.com/maps/tutorials/customizing/custom-markers
I hope it will be able to help you :)
I have a map on which I display public transit stops. I would like to color code those stops according to various parameters. I would also like to use my own icon. I have figured out how to take a png image and change its color in javascript, but I'm not sure how to get the Google Map to use it as the Marker image.
I've seen the Styled Marker library but as far as I can tell, you can't use your own image with it--and from an (admittedly cursory) look at its source, I don't think I can change it to use my image as it seems to use URL parameters with a set of default markers to achieve the color change.
Any suggestions?
You want something like this:
marker = new google.maps.Marker({
draggable: false,
raiseOnDrag: false,
icon: {
size: new google.maps.Size(32, 42),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(15, 42),
url: // path to png
},
animation: google.maps.Animation.DROP,
position: new google.maps.LatLng(lat, lng),
map: map
});
Here's the full documentation.
Hi all I need to update google markers position every 5sec
I have this javascript code for drawing a google markers when page loads.
I want to be able to change position of the markers every 5 sec.
Here is my code:
function initialize() {
var myOptions = {
zoom: 4,
center: new google.maps.LatLng(-25.363882, 131.044922),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map_canvas'),
myOptions);
var image = new google.maps.MarkerImage("images/truck3.png",
new google.maps.Size(32.0, 37.0),
new google.maps.Point(0, 0),
new google.maps.Point(16.0, 18.0)
);
var shadow = new google.maps.MarkerImage("images/shadow-truck3.png",
new google.maps.Size(51.0, 37.0),
new google.maps.Point(0, 0),
new google.maps.Point(16.0, 18.0)
);
var marker = new google.maps.Marker({
position: map.getCenter(),
map: map,
icon: image,
shadow: shadow,
title: 'Click to zoom'
});
google.maps.event.addDomListener(window, 'load', initialize);
One more thing how can I put multiple points when showing more then one marker.
I know this is probably trivial for you but I am totally new at this.
EDIT:
I am sorry but this google got me tottaly confused. So What I want to do is next. When page loads I want to retrieve and array of last positions and each of that positions will have their id so an php array would be like array[Lat][Lng][id], after that I would like to put and marker on each of that position and put it in the center of the screen. When user clicks on one marker it will automatically zoom and start putting the marker position in the center every second. And I need an id for that certain marker.
This is a similar question, it would be nice if some java guru can combine me those to to get what I need
LINK ON THE SIMILAR QUESTION
well you can get lot of support for your queries GOOGLE MAPS API V3 Documentation
there are functions like
setCenter(latlng) that changes center on run time and also the function setPosition(latlng:LatLng) to change the center of marker by this way you can change the position of your marker runtime. and for storing last locations you can use a database for it and update it as according to your requirement.
This google.maps.Marker method allows you to change the position of existing markers:
visit here setPosition(latlng:LatLng)
Create an array of the markers, loop through it updating their position.
Add this javascript function to your code ,
$(function () {
setTimeout(function () { $('#map_canvas').load(initialize); }, 50000);
})
I am looking for javascript code that display marker on top of others.
May be there is any method of GMarker that set marker on top (z-index kind of).
For solution, I destroy marker and created again. The solution works before some time (when I tried this solution) but not right now.
There is a parameter zIndexProcess.
var marker = new GMarker( latlng, { zIndexProcess: "your z index for marker" } );
Should work.
Check this link as well.
http://econym.org.uk/gmap/zindex.htm