I can create a map with a draggable marker as shown in the code below.
Instead of having the map.addOverlay(marker) execute when the map
loads, I want to have it display after the user interacts with another
button on the page. This interaction is handled by a different
function on the page and it works fine when I put
map.addOverlay(marker); into this other function. However I also need
to reset the coordinates for which that marker will appear and this is
where I have problems.
//functions that handle the general locator buttons
function someButton() {
//need to set the lat/long values!!!!
map.addOverlay(marker);
}
function initialize() {
var iconHome = new GIcon();
iconHome.image = 'http://maps.google.com/mapfiles/kml/pal3/
icon56.png';
iconHome.shadow = 'http://maps.google.com/mapfiles/kml/pal3/
icon56s.png';
iconHome.iconSize = new GSize(32, 32);
iconHome.shadowSize = new GSize(59, 32);
iconHome.iconAnchor = new GPoint(16, 16);
iconHome.infoWindowAnchor = new GPoint(16, 16);
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("mapPane"));
map.setCenter(new GLatLng(42, -93), 6);
var customUI = map.getDefaultUI();
customUI.controls.scalecontrol = false;
customUI.controls.menumaptypecontrol = true;
map.setUI(customUI);
//draggable marker
addressCenter = new GLatLng(42, -83);
marker = new GMarker(addressCenter, {icon:iconHome, draggable: true,
clickable: false});
GEvent.addListener(marker, "dragstart", function() {
});
GEvent.addListener(marker, "dragend", function() {
document.getElementById("location").value=marker.getPoint().toUrlValue();
});
//map.addOverlay(marker);
}
}
--
You received this message because you are subscribed to the Google Groups
"Google Maps API V2" 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.