javascript - Custom markers for points from a geoJson file with Google Maps -



javascript - Custom markers for points from a geoJson file with Google Maps -

i'm using geojson info source google maps. i'm using v3 of api create dat layers follows;

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script> <script> var map; function initialize() { //initialise map var mylatlng = new google.maps.latlng(53.231472,-0.539783); map = new google.maps.map(document.getelementbyid('map-canvas'), { zoom: 17, center: mylatlng, scrollwheel: false, pancontrol: false, zoomcontrol: false, scalecontrol: true, disabledefaultui: true }); //initialise base of operations folder icons var iconbase = '/static/images/icons/'; //load json show places map.data.loadgeojson('/api/geo'); } google.maps.event.adddomlistener(window, 'load', initialize); </script> <div id="map-canvas"></div>

the source of json info follows;

{ "type": "featurecollection", "features": [ { "type": "feature", "geometry": { "type": "point", "icon": "/static/images/icons/map-marker-do.png", "coordinates": [ -0.53743, 53.23437 ] }, "properties": { "name": "cathedral", "description": "one of europeĆ¢€™s finest gothic buildings, 1 time tallest building in world dominates lincoln's skyline.", "icon": "/static/images/icons/map-marker-do.png" } } ] }

what i'm trying create marker icon on map come "icon" property in json cannot figure out how info alter default marker.

i wondering if can offer advice?

thanks, neil

use styling-function(styling-functions enable apply styles based on specific feature)

map.data.setstyle(function(feature) { homecoming {icon:feature.getproperty('icon')}; });

javascript json google-maps google-maps-api-3

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -