# Google Maps API v3 - Links to marker locations?



## Gesp (Nov 29, 2008)

Hi there,

Is there anyway that I can make the Google Maps API center on a certain set of coordenates with the click of an external link?

Thanks


----------



## JiminSA (Dec 15, 2011)

I've achieved this by entering an address within the Google maps framework online - "Set default location" and then clicking the link logo to get some iframe html to embed as a link in my site. I'm sure that you can do the same using GPS settings instead of address.


----------



## allnodcoms (Jun 30, 2007)

You could (as Jim suggests) use standard links and display each page in the same iFrame, or you could look at AJAX to alter the content at runtime.

I've not used the maps api for some time (last time I used it, it was still in beta!) so it's hard to recommend one over the other, but the first option would seem the most straight forward.

Danny


----------



## JiminSA (Dec 15, 2011)

For interests sake I did a little research into this and discovered that you can make latitude/longitude https requests to the Google Maps API and receive back either Json or xml formatted output which contains an address relevant to your input, but no "link" to display the map, unfortunately - which doubtless is why you asked this question. (I shall pursue that aspect, which is after all, what you are looking for and report back, success or no).

I am probably "teaching my Grandmother to suck eggs" but here's the link which I found...
https://developers.google.com/maps/documentation/geocoding/index
for those TSG members who are curious.


----------



## JiminSA (Dec 15, 2011)

I found this...http://www.enlightenmental.com/news-blog/dynamically-using-iframe-maps-with-php-geocoding-and-google-maps-api/
Maybe it's what you're after - your ultimate objective being an iframe map link....


----------



## Gesp (Nov 29, 2008)

What I wanted is something like the *panTo* action.

Written on the Map Interactions section on https://developers.google.com/maps/documentation/javascript/v2/introduction

But I am using Google Maps API v3

Any help on how to implement it here:


```
function initialize(){
	var latlng = new google.maps.LatLng(38.697451, -9.328433);
	var centerPlace = new google.maps.LatLng(38.697551, -9.329533);
	var opt = { 
		center:centerPlace,
		zoom:17,
		mapTypeId:google.maps.MapTypeId.HYBRID,
		disableAutoPan:false,
		scrollwheel:false,
		streetViewControl:false,
		navigationControl:true,
		navigationControlOptions:{style:google.maps.NavigationControlStyle.SMALL, position:google.maps.ControlPosition.RIGHT_CENTER},
		mapTypeControl:true,
		mapTypeControlOptions:{style:google.maps.MapTypeControlStyle.DROPDOWN_MENU, position:google.maps.ControlPosition.RIGHT_TOP}
	};
	var map = new google.maps.Map(document.getElementById("mapPanel"),opt);

	var marker;
		marker = new google.maps.Marker({
        	position: new google.maps.LatLng(locations[i][1], locations[i][2]),
        	title:"myMap",
			clickable:false,
			map:map,
			icon:'Img/mapMarker.png',
		});
}
```


----------



## JiminSA (Dec 15, 2011)

So, you've tracked down your own solution!:up:

But that js code will only service one request for Latitude & Longitude - 38.697451, -9.328433

I suggest that you take a closer look at the example where you found the Initialise function and emulate their handling of a form (which contains an element called mapPanel). You would also need their marker icon (img/mapMarker.png).

Alternatively you could copy and paste the code in the link I gave you earlier into a php file you could call map.php, which you can include in your html page...

Hope that helps...


----------

