Maps/Earth Integration question

14 views
Skip to first unread message

Harold Julian

unread,
Nov 17, 2009, 7:14:28 PM11/17/09
to KML Developer Support - Google Earth Plug-in
Hi I m begginer , I m use the code playground to make a test MAPS/
EARTH integration, I need when select the EARTH I can see the street
name, the first time they work (the names appears) but when I push in
MAP and return again to 3D EARTH I can't see the street name, the
names not appears, I m attach the code html,

<!--
Copyright (c) 2009 Google inc.

You are free to copy and use this sample.
License can be found here: http://code.google.com/apis/ajaxsearch/faq/#license
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/
>
<title>Google Earth API Sample</title>
<script src="http://www.google.com/jsapi?
key=ABQIAAAA1XbMiDxx_BTCY2_FkPh06RRaGTYH6UMl8mADNa0YKuWNNa8VNxQEerTAUcfkyrr6OwBovxn7TDAH5Q"></
script>
<script type="text/javascript">
var map;
var ge;

google.load("maps", "2.x");

function init() {
map = new GMap2(document.getElementById('map3d'));
map.setCenter(new GLatLng(37, -122), 12);

var mapui = map.getDefaultUI();
mapui.maptypes.physical = false;
map.setUI(mapui);

// add 'Earth' as one of the map types
map.addMapType(G_SATELLITE_3D_MAP);

// do stuff with Earth when the user switches to it
GEvent.addListener(map, 'maptypechanged', function() {
if (ge)
return;

map.getEarthInstance(function(pluginInstance) {
ge = pluginInstance;
ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, true);


});
});
}


</script>
</head>
<body onload="init()" style="font-family: arial, sans-serif; font-
size: 13px; border: 0;">
<div id="map3d" style="width: 500px; height: 380px;"></div>
<br>
<div>Installed Plugin Version: <span id="installed-plugin-version"
style="font-weight: bold;">Loading...</span></div>
</body>
</html>

Elkhantar

unread,
Dec 3, 2009, 4:44:17 AM12/3/09
to KML Developer Support - Google Earth Plug-in
Dear Harold,

I have just tested your code (it helped me to solve a problem of my
own, so thanks for that!) and it seems that there is some error when
you check if ge exists, so it always goes through the return branch of
the if and the code afterwards is never executed. You need to either:

- Define another variable and use it to check if the ge initialization
code has been executed
- Remove the if statement and leave the listener function as it is.
Since no harmful code is executed, it should not matter much (well,
the layers are always enabled when you switch to the earth map. If you
change it somehow (e.g. through a custom control/javascript) then you
would have to take the previous option).


Hope that helps!

On 18 nov, 01:14, Harold Julian wrote:
> Hi I m begginer , I m use the code playground to make a test MAPS/
> EARTH integration, I need when select the EARTH I can see the street
> name, the first time they work (the names appears) but when I push in
> MAP and return again to 3D EARTH I can't see the street name, the
> names not appears, I m attach the code html,
>
> <!--
>   Copyright (c) 2009 Google inc.
>
>   You are free to copy and use this sample.
>   License can be found here:http://code.google.com/apis/ajaxsearch/faq/#license
> -->
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
>   <head>
>     <meta http-equiv="content-type" content="text/html; charset=utf-8"/
>
>     <title>Google Earth API Sample</title>
>     <script src="http://www.google.com/jsapi?
> key=ABQIAAAA1XbMiDxx_BTCY2_FkPh06RRaGTYH6UMl8mADNa0YKuWNNa8VNxQEerTAUcfkyrr 6OwBovxn7TDAH5Q"></
Reply all
Reply to author
Forward
0 new messages