xmux xmux - 2 years ago 108
Javascript Question

How can i jump from another web page (with an url) to a specific LatLong or to a marker on my self-created google maps (v3 JS API)?

I found a simple example, but this works only if the map and the link on the same page.


<!DOCTYPE html>
<head lang="en">
<meta charset="UTF-8">
<script src="https://maps.googleapis.com/maps/api/js?libraries=geometry,visualization,drawing,places"></script>

<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(51.522387,-0.173501);
var myOptions = {
zoom: 15,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
var map = new google.maps.Map(document.getElementById("map_canvas"),

var marker2 = new google.maps.Marker(
position: new google.maps.LatLng(51.5262405, -0.074549),
map: map,
title: "my 2nd title"

document.getElementById("marker2"), "click", function() {
return false;

<body onload="initialize()">
<div id="map_canvas" style="width:310px; height:260px"></div>
<a href="#" id="marker2">Second place</a>

Is there a way to jump to a specific location (LatLong) or directly to a marker with marker.getPosition() from another website to my self created GM Map?

Maybe with an anchor? Ex: http://www.example.com/map#marker2

Answer Source

Here example to get value of query from URL jquery get querystring from URL

Use this to inserted your code and use

map.setCenter(new gooogle.map.latlng(0,0));

for setting center map to location of marker

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download