Larry6621532
Posts: 0
Joined: Thu Jan 30, 2014 4:26 am

Google map not accepting commands

I am trying to display the Terrain map as my default but I keep getting an error.

"Uncaught TypeError: Cannot set property 'mapTypeId' of undefined "
"Cannot refresh, map is not initialized! "

It seems that my map does not get initialized
Here is the code.

var mapOptions = {
zoom: 14,
mapTypeId: google.maps.MapTypeId.Terrain
};
// Tried each of these
//var map = new google.maps.Map($('div[dsid="map"]').get(0), mapOptions);
//var map = Appery('map');

var map = new google.maps.Map(Appery('map').get(0), mapOptions);
map.gmap.mapTypeId = google.maps.MapTypeId.Terrain;
map.refresh();

What I really want to do is simply turn off the POI (points of interest) on the map and switching to the Terrain map was a backup. but I figured if I can get the simpler solution working I would take that.

var myMapOptions = {
styles:[{
featureType:"poi",
stylers:[{
visibility:"off"
}]
}]
};

Any ideas greatly appreciated?
Thanks
Larry

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Google map not accepting commands

Hi Larry,

What is your component name? Please make sure it's named 'map'.

Larry6621532
Posts: 0
Joined: Thu Jan 30, 2014 4:26 am

Google map not accepting commands

Yes it is called map. Also in the code I posted the word " Terrain" is in lower case but I did try upper case as well. In chrome with debugger showing the console a see errors or warnings that the " Cannot refresh, map is not initialized" 3 times. I only have map.refresh in my code in one place on a geocode success event. I even commented that one out and still get the message.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Google map not accepting commands

Hi Larry,

These things will help to understand:
ol
liGoogle Map component automatically create Google map instance. So you don't have to do it./li

liYou can access Google maps component when it would be initialized./li
/ol

So the code to change TypeId to "TERRAIN" should be:
pre
var onDelay = function(){
if(!Appery("map").gmap)
return window.setTimeout(onDelay, 100);

Code: Select all

 Appery("map").gmap.setMapTypeId(google.maps.MapTypeId.SATELLITE) 

};

onDelay();
/pre

Larry6621532
Posts: 0
Joined: Thu Jan 30, 2014 4:26 am

Google map not accepting commands

Your code worked perfectly and thanks for the tip on the Google map Instance.

Appery.io support through this forum is excellent.

Thanks again.
Larry

Return to “Issues”