Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>So, finally, I found the problem. </p> <p>I was requiring in my update_map.js map.js, wich has it's own instantiating of window.map. It was not suitable for this case of changing the marker. I rewrote my update_map.js and now it's using its' own instance of window.map. This is my update_map.js:</p> <pre><code>ACTIVEOBJECTICON = L.icon iconUrl: '&lt;%= image_path("green-marker.png") %&gt;', iconSize: [25, 41], iconAnchor: [13, 41] draggable: true class EditMap extends L.Map constructor: (id, params) -&gt; super id, params @layers = companyLocationMarker: new L.LayerGroup() activeObjectMarker: new L.LayerGroup() @activeObjectIcon = ACTIVEOBJECTICON @putInit() putInit: =&gt; if coord == "[0]" || coord == "" alert("You didn't setup adress.") else latLng = coord.replace('[',"").replace(']',"").split(",").map(Number) val1 = latLng[1] val0 = latLng[0] location = new L.LatLng(val1, val0) @layers.activeObjectMarker = new L.Marker(location, { icon: @activeObjectIcon} ) @addLayer(@layers.activeObjectMarker) @layers.activeObjectMarker.dragging.enable() @setView(location, 15) @panTo location setCompanyLocation: (location) =&gt; @currentLocation = location map.renderCompanyLocation() renderCompanyLocation: =&gt; locationIcon = ACTIVEOBJECTICON @removeLayer(@layers.activeObjectMarker) @removeLayer(@layers.companyLocationMarker) @layers.companyLocationMarker = new L.Marker(@currentLocation, { icon: locationIcon }) @addLayer(@layers.companyLocationMarker) @layers.companyLocationMarker.dragging.enable() @setView(@currentLocation, 15) jQuery $ -&gt; osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' osmTiles = new L.TileLayer osmUrl, maxZoom: 18 window.map = new EditMap 'map', attributionControl: false, zoom: 12, doubleClickZoom: false center: new L.LatLng(53.9060, 27.5549) map.addLayer osmTiles $("#location-detector-update").on 'click', (e) -&gt; e.preventDefault() address = $("#location-address").val() errorElement = $("#location-error") if address.length &gt; 0 $.ajax url: 'http://geocode-maps.yandex.ru/1.x/' type: 'get' data: geocode: address format: 'json' results: 1 ,success: (data) =&gt; if typeof(data) == 'string' data = JSON.parse(data) if data.response.GeoObjectCollection.featureMember.length &gt; 0 _location = data.response.GeoObjectCollection.featureMember[0].GeoObject.Point.pos.split(" ") _location[0] = 0 if _location[0] == null _location[1] = 0 if _location[1] == null location = new L.LatLng(_location[1], _location[0]) map.setCompanyLocation location $('#coordinates-val').val(_location[0] + ", " + _location[1]) map.layers.companyLocationMarker.on 'dragend', (e) -&gt; $('#coordinates-val').val(e.target._latlng.lng + ", " + e.target._latlng.lat) errorElement.html "" else errorElement.html "Unable to find" </code></pre> <p>production.rb is the same.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload