117 lines
3.0 KiB
HTML
117 lines
3.0 KiB
HTML
<!DOCTYPE HTML>
|
|
<title>OpenLayers Simplest Example</title>
|
|
<div id="demoMap" style="height:360px"></div>
|
|
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
|
|
<script>
|
|
map = new OpenLayers.Map("demoMap");
|
|
var mapnik = new OpenLayers.Layer.OSM();
|
|
|
|
|
|
var fromProjection = new OpenLayers.Projection("EPSG:4326");
|
|
var toProjection = new OpenLayers.Projection("EPSG:900913");
|
|
|
|
var position = new OpenLayers.LonLat(__LON__, __LAT__).transform( fromProjection, toProjection);
|
|
|
|
var zoom = __ZOOM__;
|
|
|
|
map.addLayer(mapnik);
|
|
|
|
map.setCenter(position, zoom );
|
|
|
|
var markers = new OpenLayers.Layer.Markers( "Markers" );
|
|
map.addLayer(markers);
|
|
|
|
selectControl = new OpenLayers.Control.SelectFeature(markers);
|
|
map.addControl(selectControl);
|
|
|
|
function AddMarker(x, y, state)
|
|
{
|
|
if (state == 0)
|
|
{
|
|
marker_addr = "http://mephi1984.jino.ru/osm/marker_mobile.png";
|
|
}
|
|
else if (state == 1)
|
|
{
|
|
marker_addr = "http://mephi1984.jino.ru/osm/marker.png";
|
|
}
|
|
else
|
|
{
|
|
marker_addr = "http://mephi1984.jino.ru/osm/marker_alarm.png";
|
|
}
|
|
|
|
var size = new OpenLayers.Size(21,25);
|
|
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
|
|
var icon = new OpenLayers.Icon(marker_addr, size, offset);
|
|
|
|
var lon_Lat = new OpenLayers.LonLat(x, y).transform(fromProjection, toProjection);
|
|
markers.addMarker(new OpenLayers.Marker(lon_Lat, icon));
|
|
}
|
|
|
|
function ActivateSelectControl()
|
|
{
|
|
selectControl.activate();
|
|
}
|
|
|
|
function DeactivateSelectControl()
|
|
{
|
|
selectControl.deactivate();
|
|
}
|
|
|
|
function Clear()
|
|
{
|
|
markers.clearMarkers();
|
|
}
|
|
|
|
function AddMarkerWithPopup(x, y, state, text)
|
|
{
|
|
|
|
if (state == 0)
|
|
{
|
|
marker_addr = "http://mephi1984.jino.ru/osm/marker_mobile.png";
|
|
}
|
|
else if (state == 1)
|
|
{
|
|
marker_addr = "http://mephi1984.jino.ru/osm/marker.png";
|
|
}
|
|
else if (state == 2)
|
|
{
|
|
marker_addr = "http://mephi1984.jino.ru/osm/marker_alarm.png";
|
|
}
|
|
else if (state == 3)
|
|
{
|
|
marker_addr = "http://mephi1984.jino.ru/osm/marker_exclusion.png";
|
|
}
|
|
else if (state == 4)
|
|
{
|
|
marker_addr = "http://mephi1984.jino.ru/osm/marker_throw.png";
|
|
}
|
|
else if (state == 5)
|
|
{
|
|
marker_addr = "http://mephi1984.jino.ru/osm/marker_carousel.png";
|
|
}
|
|
else if (state == 6)
|
|
{
|
|
marker_addr = "http://mephi1984.jino.ru/osm/marker_assault.png";
|
|
}
|
|
else
|
|
{
|
|
marker_addr = "http://mephi1984.jino.ru/osm/marker_alarm.png";
|
|
}
|
|
|
|
|
|
var size = new OpenLayers.Size(21,25);
|
|
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
|
|
var icon = new OpenLayers.Icon(marker_addr, size, offset);
|
|
|
|
var lon_Lat = new OpenLayers.LonLat(x, y).transform(fromProjection, toProjection);
|
|
|
|
var marker = new OpenLayers.Marker(lon_Lat, icon);
|
|
|
|
marker.events.register('mousedown', marker, function(evt) { alert(text); OpenLayers.Event.stop(evt); });
|
|
|
|
markers.addMarker(marker);
|
|
|
|
|
|
}
|
|
|
|
</script> |