Util.getJSON(this.options.serviceUrl + encodeURIComponent(location.lng) + ',' + encodeURIComponent(location.lat) + '.json', this.options.reverseQueryParams, function(data) { var results = [], loc, latLng, latLngBounds; if (data.features && data.features.length) { for (var i = 0; i <= data.features.length - 1; i++) { loc = data.features[i]; latLng = L.latLng(loc.center.reverse()); if (loc.hasOwnProperty('bbox')) { latLngBounds = L.latLngBounds(L.latLng(loc.bbox.slice(0, 2).reverse()), L.latLng(loc.bbox.slice(2, 4).reverse())); } else { latLngBounds = L.latLngBounds(latLng, latLng); } results[i] = { name: loc.place_name, bbox: latLngBounds, center: latLng }; } } cb.call(context, results); });
_redraw: function (id) { var layer = this._layers[id]; var geojson = layer.feature; // if this looks like a marker if (layer && layer.setIcon && this.options.pointToLayer) { // update custom symbology, if necessary if (this.options.pointToLayer) { var getIcon = this.options.pointToLayer(geojson, L.latLng(geojson.geometry.coordinates[1], geojson.geometry.coordinates[0])); var updatedIcon = getIcon.options.icon; layer.setIcon(updatedIcon); } } // looks like a vector marker (circleMarker) if (layer && layer.setStyle && this.options.pointToLayer) { var getStyle = this.options.pointToLayer(geojson, L.latLng(geojson.geometry.coordinates[1], geojson.geometry.coordinates[0])); var updatedStyle = getStyle.options; this.setFeatureStyle(geojson.id, updatedStyle); } // looks like a path (polygon/polyline) if (layer && layer.setStyle && this.options.style) { this.resetStyle(geojson.id); } }
jsonp(url, {}, L.Util.bind(function (error, attributions) { if (error) { return; } this._attributions = []; for (var c = 0; c < attributions.contributors.length; c++) { var contributor = attributions.contributors[c]; for (var i = 0; i < contributor.coverageAreas.length; i++) { var coverageArea = contributor.coverageAreas[i]; var southWest = L.latLng(coverageArea.bbox[0], coverageArea.bbox[1]); var northEast = L.latLng(coverageArea.bbox[2], coverageArea.bbox[3]); this._attributions.push({ attribution: contributor.attribution, score: coverageArea.score, bounds: L.latLngBounds(southWest, northEast), minZoom: coverageArea.zoomMin, maxZoom: coverageArea.zoomMax }); } } this._attributions.sort(function (a, b) { return b.score - a.score; }); this._updateMapAttribution(); }, this));
}, function(data) { var results = [], loc, latLng, latLngBounds; if (data.features && data.features.length) { for (var i = 0; i <= data.features.length - 1; i++) { loc = data.features[i]; latLng = L.latLng(loc.center.reverse()); if(loc.hasOwnProperty('bbox')) { latLngBounds = L.latLngBounds(L.latLng(loc.bbox.slice(0, 2).reverse()), L.latLng(loc.bbox.slice(2, 4).reverse())); } else { latLngBounds = L.latLngBounds(latLng, latLng); } results[i] = { name: loc.place_name, bbox: latLngBounds, center: latLng }; } } cb.call(context, results); });
function _getBounds(){ var southWest = L.latLng(-16.5467, 23.8898), northEast = L.latLng(-12.5653, 29.4708), bounds = L.latLngBounds(southWest, northEast); return bounds; }
jsonp(url, {}, Util.bind(function (error, attributions) { if (error) { return; } map._esriAttributions = []; for (var c = 0; c < attributions.contributors.length; c++) { var contributor = attributions.contributors[c]; for (var i = 0; i < contributor.coverageAreas.length; i++) { var coverageArea = contributor.coverageAreas[i]; var southWest = latLng(coverageArea.bbox[0], coverageArea.bbox[1]); var northEast = latLng(coverageArea.bbox[2], coverageArea.bbox[3]); map._esriAttributions.push({ attribution: contributor.attribution, score: coverageArea.score, bounds: latLngBounds(southWest, northEast), minZoom: coverageArea.zoomMin, maxZoom: coverageArea.zoomMax }); } } map._esriAttributions.sort(function (a, b) { return b.score - a.score; }); // pass the same argument as the map's 'moveend' event var obj = { target: map }; _updateMapAttribution(obj); }, this));
function onLocationFound(e) { var map = e.target, marker = map._userLocationMarker, latlng = e.latlng; // For testing, move points near Azavea to southern Manhattan var azaveaLatLng = L.latLng(39.9583208, -75.1585257), manhattanLatLng = L.latLng(40.7030809, -74.0129269); if (latlng.distanceTo(azaveaLatLng) < 1000) { latlng.lat += manhattanLatLng.lat - azaveaLatLng.lat; latlng.lng += manhattanLatLng.lng - azaveaLatLng.lng; } if (!marker) { marker = map._userLocationMarker = L.circleMarker(latlng, { color: '#0E9C4B', fillColor: '#00EB66', fillOpacity: 1.0, weight: 2, opacity: 1.0, radius: 8 }); } if (!map.hasLayer(marker)) { map.addLayer(marker); } marker.setLatLng(latlng); }
distance(a, b) { let aLatLng = Leaflet.latLng(a.coordinates[1], a.coordinates[0]); let bLatLng = Leaflet.latLng(b.coordinates[1], b.coordinates[0]); return aLatLng.distanceTo(bLatLng); }
getDistance: function(service) { if (typeof service.lat === 'undefined' || typeof service.lon === 'undefined') { return 0; } var a = L.latLng(this.props.map.lat, this.props.map.lon); var b = L.latLng(service.lat, service.lon); return Math.round(a.distanceTo(b) * 0.1) * 10; },
const filterByBoundary = (issues, boundaries) => { const bounds = L.latLngBounds( L.latLng(boundaries[0]), L.latLng(boundaries[1]) ); return issues.filter(i => { let latLng = L.latLng(i.position); return bounds.contains(latLng); }); };
export function extentToBounds (extent) { // "NaN" coordinates from ArcGIS Server indicate a null geometry if (extent.xmin !== 'NaN' && extent.ymin !== 'NaN' && extent.xmax !== 'NaN' && extent.ymax !== 'NaN') { var sw = latLng(extent.ymin, extent.xmin); var ne = latLng(extent.ymax, extent.xmax); return latLngBounds(sw, ne); } else { return null; } }
async getBounds() { if (this._geohashOptions.fetchBounds) { const geoHashBounds = await this._geohashOptions.fetchBounds(); if (geoHashBounds) { const northEast = L.latLng(geoHashBounds.top_left.lat, geoHashBounds.bottom_right.lon); const southWest = L.latLng(geoHashBounds.bottom_right.lat, geoHashBounds.top_left.lon); return L.latLngBounds(southWest, northEast); } } return this._bounds; }
fitBounds(): void { const markers = this.props.markers; const lngs = filter(map(markers, this.props.longitudeExtractor), isValid); const lats = filter(map(markers, this.props.latitudeExtractor), isValid); const ne = { lng: max(lngs), lat: max(lats) }; const sw = { lng: min(lngs), lat: min(lats) }; if (shouldIgnoreLocation(ne) || shouldIgnoreLocation(sw)) { return; } this.props.map.fitBounds(L.latLngBounds(L.latLng(sw), L.latLng(ne))); }
fitBounds(): void { const points = this.props.points; const lngs = map(points, this.props.longitudeExtractor); const lats = map(points, this.props.latitudeExtractor); const ne = { lng: max(lngs), lat: max(lats) }; const sw = { lng: min(lngs), lat: min(lats) }; if (shouldIgnoreLocation(ne) || shouldIgnoreLocation(sw)) { return; } this.props.leaflet.map.fitBounds(L.latLngBounds(L.latLng(sw), L.latLng(ne))); }
initialize: function (latlng, radius, options) { this._latlng = L.latLng(latlng); this._mRadius = Math.min(MAX_RADIUS_METERS, radius); var shape = this._computeShape(this._latlng, this._mRadius); L.MultiPolygon.prototype.initialize.call(this, shape, options); },
function setupGetShapeAndAnalyze(successCount) { var sandbox = new SandboxRegion(), model = new models.ToolbarModel(), view = new views.ToolbarView({ model: model }), shapeId = 1, e = {latlng: L.latLng(50.5, 30.5)}, ofg = model.get('outlineFeatureGroup'), grid = { callCount: 0, _objectForEvent: function() { //mock grid returns shapeId on second call this.callCount++; if (this.callCount >= successCount) { return {data: {id: shapeId}}; } else { return {}; } } }, tableId = 2; sandbox.show(view); App.restApi = { getPolygon: function() { return $.Deferred().resolve(TEST_SHAPE).promise(); } }; return views.getShapeAndAnalyze(e, model, ofg, grid, tableId); }
/** * Tile Map Maps * * @class Map * @constructor * @param container {HTML Element} Element to render map into * @param params {Object} Parameters used to build a map */ function TileMapMap(container, params) { this._container = container; this._poiLayers = {}; this._wmsOverlays = {}; // keep a reference to all of the optional params this._callbacks = _.get(params, 'callbacks'); this._setMarkerType(params.mapType); const centerArray = _.get(params, 'center') || defaultMapCenter; this._mapCenter = L.latLng(centerArray[0], centerArray[1]); this._mapZoom = _.get(params, 'zoom') || defaultMapZoom; this._setAttr(params.attr); this._isEditable = params.editable || false; var mapOptions = { minZoom: 1, maxZoom: 18, noWrap: true, maxBounds: L.latLngBounds([-90, -220], [90, 220]), scrollWheelZoom: _.get(params.attr, 'scrollWheelZoom', true), fadeAnimation: false, }; this._createMap(mapOptions); }
_decodeFeatures: function(data) { var results = [], i, f, c, latLng, extent, bbox; if (data && data.features) { for (i = 0; i < data.features.length; i++) { f = data.features[i]; c = f.geometry.coordinates; latLng = L.latLng(c[1], c[0]); extent = f.properties.extent; if (extent) { bbox = L.latLngBounds([extent[1], extent[0]], [extent[3], extent[2]]); } else { bbox = L.latLngBounds(latLng, latLng); } results.push({ name: this._decodeFeatureName(f), html: this.options.htmlTemplate ? this.options.htmlTemplate(f) : undefined, center: latLng, bbox: bbox, properties: f.properties }); } } return results; },
{stops.map((stop, idx) => <CircleMarker center={latLng(stop.lat, stop.lon)} key={`add-trip-pattern-layer-${id}-stop-${idx}`} color={colors.ADDED} radius={2.5} />)}
resolveDevelopersAddress = () => { let tiles = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { maxZoom: 18, attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors, Points © 2012 LINZ' }), latlng = L.latLng(this.state.latitude, this.state.longitude); var map = L.map('map-main', {center: latlng, zoom: 2, layers: [tiles]}); this.state.developers.map((developer, i) => { this.state.geocoder.geocode({'address': developer.address}, (results, status) => { if (status == google.maps.GeocoderStatus.OK) { let result = results[0].geometry.location; let latlog = new L.latLng(result.lat(), result.lng()); let popup1 = new L.Popup({'autoClose':false}); popup1.setLatLng(latlog); popup1.setContent("<strong><a href='#/mern-developers/" + developer.username + "'>@" + developer.username + "</a></strong>"); L.marker(latlog).addTo(map) .bindPopup(popup1).openPopup(); map.addLayer(popup1); } }); }); }
TileMap.prototype.geohashMinDistance = function (feature) { var centerPoint = feature.properties.center; var geohashRect = feature.properties.rectangle; // get lat[1] and lng[0] of geohash center point // apply lat to east[2] and lng to north[3] sides of rectangle // to get radius at center of geohash grid recttangle var center = L.latLng([centerPoint[1], centerPoint[0]]); var east = L.latLng([centerPoint[1], geohashRect[2][0]]); var north = L.latLng([geohashRect[3][1], centerPoint[0]]); var eastRadius = Math.floor(center.distanceTo(east)); var northRadius = Math.floor(center.distanceTo(north)); return _.min([eastRadius, northRadius]); };
_setPositionFromDomainIfMissing () { // TODO transform if necessary if (!this.getLatLng() && this._domains) { // in case bindPopup is not used and the caller did not set a position let x = this._domains[0].axes.get('x') let y = this._domains[0].axes.get('y') this.setLatLng(L.latLng(y.values[0], x.values[0])) } }
L.Path.prototype.rotate = function (angle, center) { var oldPoints = arrowPolyline.getLatLngs(); if (!center) { center = L.latLng(oldPoints[0].lat, oldPoints[0].lng); } else if (typeof center === 'array') { center = L.latLng(oldPoints[0][0], oldPoints[0][1]); } var newPoints = []; oldPoints.forEach(function (p) { var newPoint = L.latLng(p.lat, p.lng); newPoint.rotateLongitudeAround(10, oldPoints[0]); newPoint.rotateLatitudeAround(10, oldPoints[0]); newPoints.push(newPoint); }); this.setLatLngs(newPoints); };
function _updateManual() { if (_mode != 'manual') { return; } self.update( L.latLng(fields.latitude.val(), fields.longitude.val()), null ); }
mouseover: function (e) { var layer = e.target; // bring layer to front if not older browser if (!L.Browser.ie && !L.Browser.opera) { layer.bringToFront(); } var latlng = L.latLng(feature.geometry.coordinates[0], feature.geometry.coordinates[1]); self.showTooltip(map, feature, latlng); },
it('should save position when marker dragged', function () { marker._latlng = L.latLng([32, 24]); marker.fireEvent('dragend', {}); $scope.$digest(); expect(isolateScope.config.default_view.lat).toBe(32); expect(isolateScope.config.default_view.lon).toBe(24); });
it('should save position when map clicked', function () { map.fireEvent('click', { latlng: L.latLng([10,12]) }); $scope.$digest(); expect(isolateScope.config.default_view.lat).toBe(10); expect(isolateScope.config.default_view.lon).toBe(12); });
_renderPopup: function (latlng, error, results, response) { latlng = L.latLng(latlng); if (this._shouldRenderPopup && this._lastClick.equals(latlng)) { // add the popup to the map where the mouse was clicked at var content = this._popupFunction(error, results, response); if (content) { this._popup.setLatLng(latlng).setContent(content).openOn(this._map); } } },
_decodePolyline: function(routeGeometry) { var cs = polyline.decode(routeGeometry, this.options.polylinePrecision), result = new Array(cs.length), i; for (i = cs.length - 1; i >= 0; i--) { result[i] = L.latLng(cs[i]); } return result; },
Util.getJSON(url, params, function(data) { var results = [], loc, latLng, latLngBounds; if (data.response.view && data.response.view.length) { for (var i = 0; i <= data.response.view[0].result.length - 1; i++) { loc = data.response.view[0].result[i].location; latLng = L.latLng(loc.displayPosition.latitude, loc.displayPosition.longitude); latLngBounds = L.latLngBounds(L.latLng(loc.mapView.topLeft.latitude, loc.mapView.topLeft.longitude), L.latLng(loc.mapView.bottomRight.latitude, loc.mapView.bottomRight.longitude)); results[i] = { name: loc.address.label, bbox: latLngBounds, center: latLng }; } } cb.call(context, results); })