back to notes

bingmaps geojson in script - freelanders

http://i.imgur.com/qceaZq1.jpg

infoboxes for geojson (read from javascript rather than the URL).

FINAL.


-------------------------------------

var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
credentials: 'AgmExgPK-Ij7H84tUYfRTcxyqIJFfeBncXCU9VKbXTtLZOinxBX-7eVvNqFU8JZC',
center: new Microsoft.Maps.Location(-31.916084, 115.882574)
});


var cities = { "type":"FeatureCollection","features":[{"type":"Feature","properties":{"name":"Amberjacks","city":"Cottesloe","count":1},"geometry":{"type":"Point","coordinates":[115.75209651445,-31.995093800366]}},{"type":"Feature","properties":{"name":"Woolworths","city":"Armadale","count":1},"geometry":{"type":"Point","coordinates":[116.01522501753,-32.149487834236]}},{"type":"Feature","properties":{"name":"Muffin Break - Armadale Central Shopping Centre","city":"Armadale","count":1},"geometry":{"type":"Point","coordinates":[116.01504279301,-32.150350660086]}},{"type":"Feature","properties":{"name":"St. Francis Xavier Catholic Church","city":"","count":1},"geometry":{"type":"Point","coordinates":[115.99124372785,-32.146774773963]}},{"type":"Feature","properties":{"name":"Grovelands Primary","city":"","count":1},"geometry":{"type":"Point","coordinates":[115.999679,-32.119551]}},{"type":"Feature","properties":{"name":"The Roastery","city":"Canning Vale","count":1},"geometry":{"type":"Point","coordinates":[115.94308971818,-32.090065801088]}},{"type":"Feature","properties":{"name":"Wassup DOG","city":"","count":1},"geometry":{"type":"Point","coordinates":[115.874936,-31.952855]}},{"type":"Feature","properties":{"name":"The Royal on The Waterfront","city":"East Perth","count":1},"geometry":{"type":"Point","coordinates":[115.87823527372,-31.952431182308]} }] };

var infobox = new Microsoft.Maps.Infobox();
infobox.setOptions({ visible: false, });
infobox.setMap(map);

Microsoft.Maps.loadModule('Microsoft.Maps.GeoJson', function () {
var featureCollection = Microsoft.Maps.GeoJson.read(cities);
for (var i = 0; i < featureCollection.length; i++) {
map.entities.push(featureCollection[i]);
}
Microsoft.Maps.Events.addHandler(map.entities, 'click', function (args) {
infobox.setOptions({
location: args.target.getLocation(),
title: args.target.metadata.name,
description: args.target.metadata.city,
visible: true
});
});
});


last updated july 2019