Google maps Geojson
HTML
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
<body>
<div id="map-canvas"></div>
</body>
CSS
html, body, #map-canvas {
height: 100%;
margin: 0;
padding: 0;
}
JavaScript
var map;
var infowindow = new google.maps.InfoWindow();
function initialize() {
map = new google.maps.Map(
document.getElementById('map-canvas'),
{
zoom: 4,
center: {lat: 10.59, lng: 080.96}
});
// [START snippet-load]
// Load GeoJSON.
map.data.addGeoJson({
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"title": 'Custom point',
"type": "Point",
"coordinates": [-77.03238901390978, 38.913188059745586]
},
"properties": {
"name": "Mapbox DC",
"description": "monument"
}
}, {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-122.414, 37.776]
},
"properties": {
"name": "Mapbox SF",
"description": "harbor"
}
}]
});
map.data.setStyle({title: 'Hovering here???'});
map.data.addListener('click', function(event) {
infowindow.setContent(event.feature.getProperty('name')+"<br>"+event.feature.getProperty('description'));
infowindow.setPosition(event.latLng);
infowindow.setOptions({pixelOffset: new google.maps.Size(0,-34)});
infowindow.open(map);
});
}
google.maps.event.addDomListener(window, 'load', initialize);