pietro117
Posts: 0
Joined: Fri Mar 16, 2012 12:09 am

Amend an existing Google Map object

Hi, I have a question about Google Maps - apologies if this is obvious. Is it possible to refer to an existing map in the UI, and amend it, or do I need to create a new map each time I change it?

All the examples I have seen require creating a new instance of a map object. I don't want to do this, as I just want to add (say) markers to an existing map.

If I do have to create a new map instance each time I change it, then presumably I would have to supply all the options such as location, zoom level etc in the constructor; how can I get those values from the original map object?
Thanks
Peter

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Amend an existing Google Map object

Creating new markers is done via Google Maps JavaScript API: https://developers.google.com/maps/do.... If there is API that allows to place markers (or any other information) without creating a new map object - you can definitely use it in Tiggzi app builder.

pietro117
Posts: 0
Joined: Fri Mar 16, 2012 12:09 am

Amend an existing Google Map object

Thanks Max. There is an API that does this - you can create a marker and then call setMap to apply it to the map. My problem is that I don't know how to refer to the existing map object - Tiggr('googlemap1').get(0) seems to point to the div, not the map inside it.

On a web page they get round ths by having a public variable containing the map instance, that is initialised when the map is created, and the variable is then used every time a change is made. I'm not sure how I would go about creating this sort of variable within Tiggzi.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Amend an existing Google Map object

code
Tiggr('googlemap1').get(0)
/code

That's the element you need, I believe it's the same as this:
code
document.getElementById("map_canvas");
/code
From: https://developers.google.com/maps/do...

You can also use jQuery selector directly.

pietro117
Posts: 0
Joined: Fri Mar 16, 2012 12:09 am

Amend an existing Google Map object

Thanks Max. There is an API that does this - you can create a marker and then call setMap to apply it to the map. My problem is that I don't know how to refer to the existing map object - Tiggr('googlemap1').get(0) seems to point to the div, not the map inside it.

On a web page they get round ths by having a public variable containing the map instance, that is initialised when the map is created, and the variable is then used every time a change is made. I'm not sure how I would go about creating this sort of variable within Tiggzi.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Amend an existing Google Map object

See my reply above.

pietro117
Posts: 0
Joined: Fri Mar 16, 2012 12:09 am

Amend an existing Google Map object

Sorry Max, all the Google API documentation seems to rely on having a persistent variable containing the map object, which is then updated by subsequent events on the web page (adding markers etc.). I still don't understand how to create and retain this variable for the life of a page in my Tiggzi app.

pietro117
Posts: 0
Joined: Fri Mar 16, 2012 12:09 am

Amend an existing Google Map object

Sorry Max, all the Google API documentation seems to rely on having a persistent variable containing the map object, which is then updated by subsequent events on the web page (adding markers etc.). I still don't understand how to create and retain this variable for the life of a page in my Tiggzi app.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Amend an existing Google Map object

If Google Map API works that way, there is nothing we can do. You would run into the same issue if you didn't use Tiggzi app builder.

Return to “Issues”