简体   繁体   中英

How can i pass latitude and longtitude variables to create google map preview

I have created the following script and i need to pass the lat and long variables to the url in order to create a google map preview. I need to make the preview on window.open with a hybrid map, marker and define zoom.

<script type="text/javascript">
function geoPreview(lat,long) {
var elemA = document.getElementById("lat").value;
var elemB = document.getElementById("long").value;

window.open('http://maps.google.com/maps?q='+elemA+', '+elemB+');
}
</script>

Any help would be appreciated. Thanks.

I don't like google maps. So here the OpenStreetmap-Solution :D

window.open('http://www.openstreetmap.org/?mlat='+elemA+'&mlon='+elemB);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM