lundi 1 décembre 2014

L.esri.featureLayer shows up and sometimes not


I'm new to the leaflet/esri subject so please forgive me if it's just a simple question.


I wrote my first webmap-app. It uses different sources. The main aim is to show two basemaps hosted by MapBox with an AGS layer coming from a different source.


Mapbox does not make any trouble. The problem is the AGS layer. It's address is: http://ift.tt/1xW2dOu


My script shows four different behaviours. I tested it with two different AG Servers.:




  1. Test with http://ift.tt/1xW2dOu a: It shows up in IE10 correctly b: Not showing up in FF 33




  2. Test with the same script but a different AGS http://ift.tt/1rN59Hu a: Shows up in IE 10 b: Shows up in FF 33




Well, what is the error in this script? The geoportal1's AGS seems to work properly. FF understands the script. But what's not working? If I use L.esri.dynamicMapLayer instead of L.esri.featureLayer the layer shows up. But for further uses I need the L.esri.featureLayer.


I also published it here: http://ift.tt/1pGj6eA


Hopefully someone can help! Thanks



<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>A simple map</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>

<div id='map'></div>

<script src='http://ift.tt/1tdT5S2'></script>
<link href='http://ift.tt/1tAtWhb' rel='stylesheet' />

<!-- Load Esri Leaflet from CDN -->
<script src="http://ift.tt/1prjbCL"></script>

<script>

L.mapbox.accessToken = 'pk.eyJ1IjoiaG9nZTZiMDEiLCJhIjoiU2FXX0xJMCJ9.WfLHHkqFGqlFgiOkmxgRDA';

var geocoder = L.mapbox.geocoder('mapbox.places-v1');

var redmap = L.mapbox.map('map')
.addControl(L.mapbox.geocoderControl('mapbox.places-v1', {
autocomplete: true
}));

geocoder.query('Cologne', showMap);

function showMap(err, data) {
// The geocoder can return an area, like a city, or a
// point, like an address. Here we handle both cases,
// by fitting the map bounds to an area or zooming to a point.
if (data.lbounds) {
redmap.fitBounds(data.lbounds);
} else if (data.latlng) {
redmap.setView([data.latlng[0], data.latlng[1]], 13);
}
}

var RedLayer = L.mapbox.tileLayer('hoge6b01.kb0pcgai'),
PencilMap = L.mapbox.tileLayer('examples.a4c252ab').addTo(redmap);

var baseMaps = {
"Red": RedLayer,
"Pencil": PencilMap
};

var greenIcon = L.icon({
iconUrl: 'http://ift.tt/1yklQ1G',
shadowUrl: 'http://ift.tt/1yklS9S',

iconSize: [38, 95], // size of the icon
shadowSize: [50, 64], // size of the shadow
iconAnchor: [22, 94], // point of the icon which will correspond to marker's location
shadowAnchor: [4, 62], // the same for the shadow
popupAnchor: [-3, -76] // point from which the popup should open relative to the iconAnchor
});


// http://ift.tt/1xW2dOu
var kita = L.esri.featureLayer('http://ift.tt/1rN59Hu' , {
pointToLayer: function (geojson, latlng) {
return L.marker(latlng, {
icon: greenIcon
});
},
}).addTo(redmap);

var overlayMaps = {
"Kita": kita
};

L.control.layers(baseMaps, overlayMaps).addTo(redmap);

</script>

</body>
</html>




Aucun commentaire:

Enregistrer un commentaire