-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathreportcrime.js
74 lines (44 loc) · 2.13 KB
/
reportcrime.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";
var extents = new OpenLayers.Bounds(4079939, -162296, 4131475, -127987);
var control, controls = [];
var map = new OpenLayers.Map("map", {
controls: [
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.ArgParser(),
//new OpenLayers.Control.Attribution(),
new OpenLayers.Control.LayerSwitcher(),//({'div':OpenLayers.Util.getElement('customlayerswitcher')});
//new OpenLayers.Control.MousePosition(),
//new OpenLayers.Control.ScaleLine(),
new OpenLayers.Control.Zoom(),
//new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.KeyboardDefaults()
],
maxExtent: extents,
minExtent: "auto",
restrictedExtent: extents
},
{projection: new OpenLayers.Projection("EPSG:900913")},
{units: 'm'},
{allOverlays: true}
);
//var google_sat = new OpenLayers.Layer.Google("Google Satellite",{type:google.maps.MapTypeId.SATELLITE,numZoomLevels:40});
var OSM = new OpenLayers.Layer.OSM("OpenStreetMap");
map.addLayers([OSM]);
map.setCenter(new OpenLayers.LonLat(4099485,-142884),15 );
var markers = new OpenLayers.Layer.Markers( "Markers" );
map.addLayer(markers);
var size = new OpenLayers.Size(38,38);
var icon = new OpenLayers.Icon('marker.png',size);
//icon = new OpenLayers.Icon('red-dot.png');
map.events.register("click", map, function(evt) {
var lonlat = map.getLonLatFromViewPortPx(evt.xy);
// var pos = map.getLonLatFromPixel(evt.xy);
markers.addMarker(new OpenLayers.Marker(lonlat,icon));
var proj_4326 = new OpenLayers.Projection('EPSG:4326');
var proj_900913 = new OpenLayers.Projection('EPSG:900913');
var hdms = new OpenLayers.LonLat(lonlat.lon, lonlat.lat);
hdms.transform(proj_900913,proj_4326 );
//var hdms= new OpenLayers.Projection.transform (lonlat,'EPSG:900913','EPSG:4326');
document.getElementById('element_12_1').value= hdms.lon ;
document.getElementById('element_12_2').value= hdms.lat;
});