Remove Marker - Google Maps Javascript API v3 -
Trying the Thai Maps API I add a trapped marker to remove the markers works great, but delete work Is not any idea why this will not work? thank you in advanced!
Function Placemarker (Events) {var marker = new google.maps.Marker ({clickable: true, position: event.latLng, map: map}); } Function deleteMarker () {marker.setMap (empty); Marker = null; } Initialize function () {var mapOptions = {zoom: 8, center: home}; Map = new google.maps.Map (document.getElementById ('map-canvas'), map options); Google.maps.event.addListener (map, 'rightclick', placeMarker); Google.maps.event.addListener (Marker, 'Click', Delete Marker); } Google.maps.event.addDomListener (window, 'load', start);
global variable defined
var map, marker , Home = new google.maps.LatLng (46.5, 13.5); Error message in the result: Unkit type error: The property '__e3_' for undefined main.js can not be read: 15 < / Pre> line
google.maps.event.addListener (marker, 'click', remove marker); marker is still undefined because it is not created and event listener can not be attached to it. This line has to be moved to placeMarker () function: function in the place marker (event) {marker = new google.maps.Marker ({clickable: true , position: event.latLng, map: map}); Google.maps.event.addListener (Marker, 'Click', Delete Marker); }
Comments
Post a Comment