Google Earth Api- own pictures
Using t开发者_运维技巧he Google Earth API I have created some placemarks at specific coordinates. Now I would also like to place an image at the same coordinates as the placemarks in order to show the users something more meaningful than the default marker icon. Is there any way to do this?
Any image can be used as a placemark's icon.
To do this you just create a Placemark then set its style to a custom style that points to your image file.
This way the image you require will be at the same coordinates as the Placemark.
Something like the following will work, obviously you would need to change http://yourserver/yourimage.png
to point to the image:
// Create the placemark.
var placemark = ge.createPlacemark('');
placemark.setName("placemark");
// Define a custom icon.
var icon = ge.createIcon('');
icon.setHref('http://yourserver/yourimage.png');
var style = ge.createStyle(''); //create a new style
style.getIconStyle().setIcon(icon); //apply the icon to the style
placemark.setStyleSelector(style); //apply the style to the placemark
// Set the placemark's location.
var point = ge.createPoint('');
point.setLatitude(12.345);
point.setLongitude(54.321);
placemark.setGeometry(point);
// Add the placemark to Earth.
ge.getFeatures().appendChild(placemark);
For more information see the section on Placemarks in the API documents. http://code.google.com/apis/earth/documentation/placemarks.html
You can use a KmlPhotoOverlay
api reference: http://code.google.com/apis/earth/documentation/reference/interface_kml_photo_overlay-members.html
example: http://earth-api-samples.googlecode.com/svn/trunk/examples/photo-overlay-viewer.html
精彩评论