I have an add marker button on the map. when I click on that and place the mouse on the map I have to do below things
1) my mouse icon should change from hand symbol to +
2) display direction and lat-long on mouse move. something like this
3) when I click on any place I should be able to add a marker to that place.
4) I should be able to add only one marker on button click
5) Once I add the marked I have to display that marker's lat-long values in my search text box
Here is my code :
function myMap() {
var myCenter = new google.maps.LatLng(56.1304, -106.3468);
var mapProp = {
center: myCenter,
zoom: 6,
scrollwheel: true,
draggable: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"), mapProp);
google.maps.event.addListener(map, 'click', function (event) {
placeMarker(event.latLng);
});
function placeMarker(location) {
var marker = new google.maps.Marker({
position: location,
animation: google.maps.Animation.DROP,
map: map
});
}
}
<div id="map" style="height: 100%; width: 100%; position: absolute; top: 0px; left: 0px; "></div>
<div>
<input id="searchtext" type="text" value=" " class="search-text" placeholder="Enter your search location here" style="z-index: 0; position: absolute; left: 125px; top: 0px;">
</div>
<div class="tool" id="addmarker" data-color='blue' style="z-index: 0; position: absolute; left: 0px; top: 289px;">
<img id="addmarkerbutton" class="map-tool-icon" title="Add Marker" src="~/Images/search.png" alt="Add Marker">
</div>