How would I be able to add pin in Bing Maps api with this code:
import Ember from 'ember';
export default Ember.Component.extend({
attributeBindings: ['style'],
classNames: ['bing-map'],
bingKey: "bing-key",
width: '45%',
height: '100%',
latitude: 0,
longitude: 0,
zoom: 0,
mapTypeId: 'r', // r:road, a:aerial
init: function(){
this._super();
if (!this.get('bingKey')){
throw('Missing bingKey');
}
this.api = Microsoft.Maps;
this.map = null;
},
style: function(){
return "position: relative; width: %@px; height: %@px".fmt(
this.get('width'),
this.get('height')
);
}.property('width', 'height'),
center: function(){
var latitude = parseFloat(this.get('latitude'));
var longitude = parseFloat(this.get('longitude'));
longitude = this.api.Location.normalizeLongitude(longitude);
return new this.api.Location(latitude, longitude);
}.property('latitude', 'longitude'),
mapOptions: function(){
return {
center: this.get('center'),
zoom: parseInt(this.get('zoom'),10),
mapTypeId: this.get('mapTypeId')
};
}.property('center','zoom','mapTypeId'),
createMap: function(){
var el = this.$()[0];
var options = this.get('mapOptions');
options.credentials = this.get('bingKey');
this.map = new Microsoft.Maps.Map(el, options);
}.on('didInsertElement'),
removeMap: function(){
this.map.dispose();
}.on('willDestroyElement'),
});
I am using ember-cli and trying to set pins on the map depending on the item that is chosen inside the template table, but I am unable to get how to set a pin on the map implemented in this code (which I need). The info in the Microsoft Bing Map api website is not helping.
Anyone know how to achieve this? Thanks in advance
Aucun commentaire:
Enregistrer un commentaire