Google Maps

  

So why does this not work:


Map1.gMap.setCenter(new google.maps.LatLng(10.23,123.45));


Get --- cannot read property 'setcenter' of undefined


Any help appreciated.

Well, the call is to setCenter, while the error message mentions setcenter. So, given JavaScript is case-sensitive, I would posit the problem is a typo somewhere...

Kilian Hekhuis wrote:

Well, the call is to setCenter, while the error message mentions setcenter. So, given JavaScript is case-sensitive, I would posit the problem is a typo somewhere...

Ah, I manually typed the last bit as in the error message. Assure you it did say setCenter. Any clue as to why the googlemaps API does not seem to work in outsystems?


Well, the Google map API works for sure, as my collegues have succesfully implemented it. I'll ask around to see if they have clue.

We use the following call to Pan and zoom to a location


Script

var map = osGoogleMap.OSMaps[ $parameters.MapId ].gMap;

map.setZoom($parameters.ZoomLevel);
map.panTo(new google.maps.LatLng($parameters.Lat, $parameters.Long));

Matthias Preuter wrote:

We use the following call to Pan and zoom to a location


Script

var map = osGoogleMap.OSMaps[ $parameters.MapId ].gMap;

map.setZoom($parameters.ZoomLevel);
map.panTo(new google.maps.LatLng($parameters.Lat, $parameters.Long));

I did this and got cannot read property  "gMap" of undefined      as an exception.

I think I am about to give up on outsystems as already spent 2 days on it and not worth much more expenditure.



Which component do you use?  Web or Mobile?

Matthias Preuter wrote:

Which component do you use?  Web or Mobile?


I am using the mobile as for a tablet. Is that my error?

No that's ok; without the "Map1.gMap.setCenter(new google.maps.LatLng(10.23,123.45));" did you see an Map on the screen?

Hi Mike,

Just to clarify: are you making a mobile app, or a web app? A web app on a tablet still needs the web version of Google Maps (the left one in Matthias' image).

Matthias Preuter wrote:

No that's ok; without the "Map1.gMap.setCenter(new google.maps.LatLng(10.23,123.45));" did you see an Map on the screen?

Yes there is a map on the screen which I can move around but it does not respond to any API calls such as setCenter. Maybe I am just not clued up enough about the outsystems platfoem but it "seems" straight forward.


Kilian Hekhuis wrote:

Hi Mike,

Just to clarify: are you making a mobile app, or a web app? A web app on a tablet still needs the web version of Google Maps (the left one in Matthias' image).

then I am confused as I only get to choose one of them.


Hi Mike,

For our understanding, could you please answer my question: are you making a mobile app, or a web app? Or is this what your confusion is about?

I created the following action (with paramter a_MapId, a_Lat, a_Long and a_Zoom) to Zoom and Pan to a location:

The JavaScript needs the MapId; so it can only be used after the initialization of the Map; so I use this action in the MapInitialized event handler of the GoogleMaps/Map webblock.

I'll publish the GoogleMapsAddon module with this action to the Forge now.

Hope this helps.

Matthias Preuter wrote:

I created the following action (with paramter a_MapId, a_Lat, a_Long and a_Zoom) to Zoom and Pan to a location:

The JavaScript needs the MapId; so it can only be used after the initialization of the Map; so I use this action in the MapInitialized event handler of the GoogleMaps/Map webblock.

I'll publish the GoogleMapsAddon module with this action to the Forge now.

Hope this helps.

Hi, the map is on the screen when I run the mobile app so I presume it is initialised. As for the PanTo_And_zoom you show above it is not there on mine. I guess time to move on to another product unless I can see something that resembles my environment. Thanks for you help.


Mike Beech wrote:

Matthias Preuter wrote:

I created the following action (with paramter a_MapId, a_Lat, a_Long and a_Zoom) to Zoom and Pan to a location:

The JavaScript needs the MapId; so it can only be used after the initialization of the Map; so I use this action in the MapInitialized event handler of the GoogleMaps/Map webblock.

I'll publish the GoogleMapsAddon module with this action to the Forge now.

Hope this helps.

Hi, the map is on the screen when I run the mobile app so I presume it is initialised. As for the PanTo_And_zoom you show above it is not there on mine. I guess time to move on to another product unless I can see something that resembles my environment. Thanks for you help.


this is what I have:



Please follow the following steps; this is the way we run it in our production Mobile App.

  • Goto the screen the has the GoogleMapsMobile\Map and select this widget
  • Add a <New client action>  to the Event MapInitialized

  • Now add the PositionPanTo action (from GoogleMapsAddon) to the MapMapInitialize action and set the MapId, lat/long and Zoomlevel

Hope this helps.

Matthias

@Mike Beech did the solution above help you? Do you have any other questions about that I can help with?

Kind regards,

Matthias

Matthias Preuter wrote:

@Mike Beech did the solution above help you? Do you have any other questions about that I can help with?

Kind regards,

Matthias

Sadly no. My screens look nothing like yours but thanks anyway.