Results 1 to 6 of 6

Thread: Google earth API.. add to my website

  1. #1
    Junior Member
    Join Date
    Jul 2009
    Posts
    4

    Default Google earth API.. add to my website

    Hi,

    Morning to everyone.

    I have set up my google earth for my website yo can see what it looks like here
    http://www.leehughes.co.uk/Route/3droute.html

    Anyway, am totally at a lost to figure out how to add placemarks.. Google provides code that I do not understand.

    http://code.google.com/apis/earth/do...f_Google_Earth

    As you can tell I edited the hello earth to embed it in my website.

    Is there an easier way of doing this all?

    Can't I just create a KML file via google earth, add all my placemarks on it and get it to look like it does on my website?

    If not, how do I add placemarks to my map?

    Thanks

  2. #2
    Super Moderator
    Join Date
    Jan 2006
    Location
    Denmark
    Posts
    2,777

    Default

    Hi leehughes.

    Welcome to GEH.

    It's very easy, just follow the directions here:

    http://www.gearthhacks.com/forums/showthread.php?t=1509

  3. #3
    Junior Member
    Join Date
    Jul 2009
    Posts
    4

    Default

    Hi,

    Thanks for your reply..

    I am aware of how to add placemarks in google earth but my trouble is how to add them on my website.

    Google says I have to use this code
    Code:
    var ge;
    
    var counter = 0;
    
    google.load("earth", "1");
    
    function init() {
      google.earth.createInstance('map3d', initCallback, failureCallback);
    
      addSampleButton('Create a Placemark!', buttonClick);
    }
    
    function initCallback(instance) {
      ge = instance;
      ge.getWindow().setVisibility(true);
    
      // add a navigation control
      ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);
    
      // add some layers
      ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
      ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, true);
    
      var la = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
      la.setRange(100000);
      ge.getView().setAbstractView(la);
    
      createPlacemark();
    
      document.getElementById('installed-plugin-version').innerHTML =
        ge.getPluginVersion().toString();
    }
    
    function failureCallback(errorCode) {
    }
    
    function createPlacemark() {
      var placemark = ge.createPlacemark('');
      placemark.setName("placemark" + counter);
      ge.getFeatures().appendChild(placemark);
    
      // Create style map for placemark
      var icon = ge.createIcon('');
      icon.setHref('http://maps.google.com/mapfiles/kml/paddle/red-circle.png');
      var style = ge.createStyle('');
      style.getIconStyle().setIcon(icon);
      placemark.setStyleSelector(style);
    
      // Create point
      var la = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
      var point = ge.createPoint('');
      point.setLatitude(la.getLatitude());
      point.setLongitude(la.getLongitude());
      placemark.setGeometry(point);
    
      counter++;
    }
    
    function buttonClick() {
      createPlacemark();
    }
    Am pretty confused by this.

    Is it possible to add placemarks in google earth then somehow get that kml file embeded into my website
    http://www.leehughes.co.uk/Route/3droute.html


    Many thanks again for your reply

  4. #4
    Super Moderator
    Join Date
    Jan 2006
    Location
    Denmark
    Posts
    2,777

    Default

    Oh, now I got it. It's the same as our administrator Mickey has made for our site to show a placemark in GE.

    He must know it.

    Maybe another member in our community can help you. We have some members who knows much about html. They are often online.

    Good luck.

  5. #5
    Junior Member
    Join Date
    Jul 2009
    Posts
    4

    Default

    many thanks for your reply again..

    I have just this second figured it out


    I uploaded my kml file rather than my kmz file that's why my placemarks were not showing.

    I knew it would be something simple! lol

  6. #6
    Junior Member
    Join Date
    Jul 2009
    Posts
    4

    Default

    Me again

    I got it to work with all my placemarks etc etc

    Does anyone know how to stop it zooming in so much?

    Everytime it loads it zooms to the same placemark, I don't remember doing anything special to it or anything.

    Quite strange

    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •