<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(JAK.gel("mapa"), jh, 8); mapa.addDefaultLayer(SMap.DEF_BASE).enable();
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 marker3 = new SMap.Marker(brno); var card = new SMap.Card(); card.getBody().innerHTML = "Tady někde jsme."; marker3.decorate(SMap.Marker.Feature.Card, card); layer.addMarker(marker3);
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);
var click = function(e) { var coords = SMap.Coords.fromEvent(e.data.event, mapa); new SMap.Geocoder.Reverse(coords, reverseResponse); } var reverseResponse = function(g) { alert(g.getResults().label); }
Loader.async = true; Loader.load(null, {api:"simple", jak:false}, mujCallback);
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 */
var signals = mapa.getSignals(); signals.addListener(window, "map-click", "click"); var click = function(e) { var coords = SMap.Coords.fromEvent(e.data.event, mapa); new SMap.Geocoder.Reverse(coords, reverseResponse); }