Ondřej Žára, Seznam.cz
<script src="http://api4.mapy.cz/loader.js"></script>
<script>Loader.load();</script>
<div id="mapa" style="width:800px; height:500px;"></div>
var jh = SMap.Coords.fromWGS84(15, 49.14);
var mapa = new SMap(document.querySelector("#mapa"), jh, 8);
mapa.addDefaultLayer(SMap.DEF_BASE).enable();
SMap.Coords
.toXYZ()
var jh = SMap.Coords.fromWGS84(15, 49.14);
/* alternativně: fromPP, fromUTM33, fromEXIF, fromEvent */
mapa.setCenter(jh);
alert(jh.toWGS84(2));
/* alternativně: toPP, toUTM33, toPixel */
mapa.addDefaultControls();
mapa.addDefaultContextMenu();
mapa.addControl(new SMap.Control.Overview(), {left:"0px", bottom:"20px"});
mapa.addControl(new SMap.Control.Minimap(), {right:"3px", bottom:"30px"});
var c = new SMap.Control.Layer();
c.addDefaultLayer(SMap.DEF_BASE);
c.addDefaultLayer(SMap.DEF_OPHOTO);
c.addDefaultLayer(SMap.DEF_TURIST);
mapa.addControl(c, {left:"0px", top:"0px"});
var layer = new SMap.Layer.Marker();
mapa.addLayer(layer).enable();
var marker1 = new SMap.Marker(jh);
layer.addMarker(marker1);
var marker2 = new SMap.Marker(praha);
marker2.decorate(SMap.Marker.Feature.Draggable);
layer.addMarker(marker2);
var card = new SMap.Card();
card.getBody().innerHTML = "Jindřichův Hradec";
marker1.decorate(SMap.Marker.Feature.Card, card);
var souradnice = [...];
var vrstva = new SMap.Layer.Geometry();
mapa.addLayer(vrstva).enable();
var polygon = new SMap.Geometry(SMap.GEOMETRY_POLYGON, null, souradnice);
vrstva.addGeometry(polygon);
new SMap.Geocoder("brno", function(geocoder) {
var results = geocoder.getResults()[0].results;
alert(results[0].label);
alert(results[0].coords);
});
var coords = SMap.Coords.fromWGS84(17.012167, 50.055132);
new SMap.Geocoder.Reverse(coords, function(geocoder) {
alert(geocoder.getResults().label);
});
var coords = [SMap.Coords.fromWGS84(14, 50), SMap.Coords.fromWGS84(18, 49)];
new SMap.Route(coords, function(route) {
var results = route.getResults();
alert(results.length); /* v metrech */
});
var shlukovac = new SMap.Marker.Clusterer(mapa);
znackovaVrstva.setClusterer(shlukovac);
var gpx = new SMap.Layer.GPX(xmlDoc);
mapa.addLayer(gpx);
gpx.enable();
gpx.fit();
var layer = new SMap.Layer.Marker();
mapa.addLayer(layer).enable();
var dataProvider = mapa.createDefaultDataProvider();
dataProvider.setOwner(mapa);
dataProvider.addLayer(layer);
dataProvider.setMapSet(SMap.MAPSET_BASE);
dataProvider.enable();
Prostor pro otázky
Ondřej Žára, vývojář, ondrej.zara@firma.seznam.cz