How To Highlite Region Of Dropdown Selected Area On Google Map
How to highlight dropdown selected area region on google map, but I want this through jQuery or javascript, My actuall requirement is like this dropdown is autocomplete address and
Solution 1:
The following example demonstrates how to display location on user selection:
Example
var locations = [
{ City: 'New York', Location: '!1m18!1m12!1m3!1d193578.74109040972!2d-73.97968099999999!3d40.703312749999995!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x89c24fa5d33f083b%3A0xc80b8f06e177fe62!2sNew+York%2C+Yhdysvallat!5e0!3m2!1sfi!2sfi!4v1442836316382' },
{ City: 'Los Angeles', Location: '!1m18!1m12!1m3!1d423284.5905135276!2d-118.41173249999996!3d34.020498899999986!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x80c2c75ddc27da13%3A0xe22fdf6f254608f4!2sLos+Angeles%2C+CA%2C+USA!5e0!3m2!1sen!2s!4v1442834158072' }
];
var seloption = "";
$.each(locations, function (i) {
seloption += '<option value="' + locations[i].Location + '">' + locations[i].City + '</option>';
});
$('#optLocations').append(seloption);
$('#optLocations').on('change', function () {
var src = "https://www.google.com/maps/embed?pb=" + this.value;
$('#embedMap').attr('src', src);
});
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><selectid="optLocations" ><optiondisabledselected> -- select a location -- </option></select><br/><iframeid="embedMap"width="600"src="about:blank"height="450"frameborder="0"style="border:0"allowfullscreen='true'></iframe>
Example 2
Using Google Maps Embed API
var locations = [
{ City: 'New York' },
{ City: 'Los Angeles' },
{ City: 'Moscow' },
{ City: 'Paris' }
];
var seloption = "";
$.each(locations, function (i) {
seloption += '<option value="' + locations[i].City + '">' + locations[i].City + '</option>';
});
$('#optLocations').append(seloption);
$('#optLocations').on('change', function () {
//the key is provided for demonstration purposes only! var embedUrl = 'https://www.google.com/maps/embed/v1/place?key=AIzaSyB-MCwhB8ITpjZQyznpnJtPP0ca-62s-jw&q=' + this.value;
$('#embedMap').attr('src', embedUrl);
});
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><selectid="optLocations" ><optiondisabledselected> -- select a location -- </option></select><br/><iframeid="embedMap"width="600"src="about:blank"height="450"frameborder="0"style="border:0"allowfullscreen='true'></iframe>
Post a Comment for "How To Highlite Region Of Dropdown Selected Area On Google Map"