I am working on some frontend functionality, and am aggregating multiple map pins in one map. I'm using Google maps v3.
At one point, I need to focus (pan+zoom) on a specific marker - or lat/lng coordinates, if that's easier.
Can you please give me a suggestion on how to do that? I was looking for how to access the google maps instance, but it seems to be used within a local scope. So I don't think I'm meant to access it.
I tried setting the zoom and center properties, and then refresh the map - but it doesn't do anything:
var lat: number = 55.711311;
var lng: number = 9.536354;
var map: google.maps.Map = terratype.providers['Terratype.GoogleMapsV3'].maps[0].handle;
map.setZoom(20);
map.setCenter({ lat, lng });
It would be better to gain access to the google map using the Terratype js onload event, and then storing that value in something global for use later.
In the example below, which needs to be placed after you use @Html.Terratype(), I have presumed there is a button somewhere with an id of 'carnivaltime', that whenever it is clicked the map will zoom to Rio de Janeiro.
How to focus a pin from JS
Hello there, and thank you for a great plugin!
I am working on some frontend functionality, and am aggregating multiple map pins in one map. I'm using Google maps v3.
At one point, I need to focus (pan+zoom) on a specific marker - or lat/lng coordinates, if that's easier.
Can you please give me a suggestion on how to do that? I was looking for how to access the google maps instance, but it seems to be used within a local scope. So I don't think I'm meant to access it.
I tried setting the zoom and center properties, and then refresh the map - but it doesn't do anything:
I found how to do it:
Hi Jan,
It would be better to gain access to the google map using the Terratype js onload event, and then storing that value in something global for use later.
In the example below, which needs to be placed after you use @Html.Terratype(), I have presumed there is a button somewhere with an id of 'carnivaltime', that whenever it is clicked the map will zoom to Rio de Janeiro.
(I have not tested the above code, it might/will contain errors)
Cheers
Jonathan Richards
is working on a reply...