Po dodaniu pacjenta do mojego app angularjs:angularjs Ulotka GetMap() nie działa
<leaflet id="map" defaults="defaults" center="center" bounds="bounds" controls="controls" event-broadcast="events"></leaflet>
i ustawienie go:
// Initialise the feature group to store editable layers
var drawnItems = new L.FeatureGroup();
// Initialise the draw control
var drawControl = new L.Control.Draw({
position: 'topright',
edit: {
featureGroup: drawnItems
}
});
// Configure Leaflet
angular.extend($scope, {
defaults: {
zoomControlPosition: 'topright',
minZoom: 3,
tileLayerOptions: {
detectRetina: true,
reuseTiles: true,
attribution: '<a href="http://osm.org">OpenStreetMaps</a>'
}
},
center: {},
controls: {
custom: [drawControl]
},
events: {
map: {
enable: ['click']
}
}
});
Po tym kodzie nie dostać ocenianej (brak błąd został wyświetlony):
leafletData.getMap().then(
function (map) {
alert('I have accessed the map.');
}
);
To powinno pokazać mi alert od razu, chociaż nic się nie dzieje.
Jeśli opóźnię ten poprzedni kod, na przykład uruchomię go w funkcji kliknięcia przycisku, działa!
Czy ktoś wie, co może być problemem?
Widząc przykład, to powinno działać: https://github.com/tombatossals/angular-leaflet-directive/blob/master/examples/control-draw-example.html
CZĘŚCIOWO SOLVED
Usuwanie ID z leaflet
tagu HTML rozwiązał problem. To musi być błąd.
Miałem ten sam problem. Zgłosiłeś to? – schmijos
Tak, zrobiłem to kilka miesięcy temu - nie podjęto jeszcze żadnych działań. – Julius
Masz przekazać identyfikator znacznika do funkcji getMap() w następujący sposób: leafletData.getMap ('theMap'). Then then ... –
Dojo