Page 1 of 1

Amend an existing Google Map object

Posted: Fri Mar 30, 2012 3:01 pm
by pietro117

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


Amend an existing Google Map object

Posted: Fri Mar 30, 2012 3:59 pm
by maxkatz

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.


Amend an existing Google Map object

Posted: Fri Mar 30, 2012 4:23 pm
by pietro117

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.


Amend an existing Google Map object

Posted: Fri Mar 30, 2012 4:27 pm
by maxkatz

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.


Amend an existing Google Map object

Posted: Fri Mar 30, 2012 4:30 pm
by pietro117

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.


Amend an existing Google Map object

Posted: Fri Mar 30, 2012 4:33 pm
by maxkatz

See my reply above.


Amend an existing Google Map object

Posted: Mon Apr 02, 2012 7:37 am
by pietro117

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.


Amend an existing Google Map object

Posted: Mon Apr 02, 2012 7:37 am
by pietro117

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.


Amend an existing Google Map object

Posted: Mon Apr 02, 2012 4:01 pm
by maxkatz

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.