Scenario:
I want to be able to drop items to Google Map & used the searchbox at the same time. Dragged "New York" (ui.draggable.text()) listed draggable item into Google map, it'll pull up the New York center in the good map.
Result:
It works but it covers the original "Place Search box" and I lose the searchbox completely since it populates a new map... Not sure how to adjust the below code so I save up all the dropped item + options to remove and keep the searchbox
Droppable div on the map:
$('.dropit').droppable({
drop: function(event, ui) {
geocoder = new google.maps.Geocoder();
var address = ui.draggable.text();
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
var mapOptions = {
// center: ui.draggable.text().geometry.location(),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
//ui.draggable.text() DISPLAY THIS ON MAP
}
});