Drupal OpenLayers how to solve : The layer cannot be reprojected to the map projection: EPSG: - drupal-7

Here is my adventure. On this page I would like to display our bicycle route.
I am using in drupal 7:
Openlayers 7.x-2.0-beta3
OpenLayers KML Layer 7.x-1.0-beta1 (I'm not sure if I need this module as well)
layer: openlayers_kml_example with the source a url to a file.
map : example_kml Example KML Map
The result is that the layer is displayed very very small on the big map. So if you zoom in to the airplane eventually you can see the track.
Map Projection set to 3857
Display Map Projection set to 4326 (the KML is made with Google earth. I think not important as there is no interaction only displaying.
LAYER SPECIFIC OPTIONS FOR KM extract styles and attributes ON.
If I put tracks on then I will miss the nice airplane icon.
I keep getting the same logs and of course no display on the page:
MESSAGE The layer cannot be reprojected to the map projection: EPSG:
MESSAGE Notice: Undefined variable: map in openlayers_layer_sanity_check() (line 399
MESSAGE Notice: Undefined property: stdClass::$name in openlayers_layer_sanity_check()
As it is not nice for people to think that I'm cycling constantly in water I would like to solve it :-)
Any suggestions?

John is correct in describing the issues but here is the solution :-)
Update drupal module openlayers to the latest version, currently 7.x-2.0-beta9.
Take care of the needed dependencies.
I reset all my layers and maps to the orginial and then adjusted the source of the kml layer to a file.

Related

Mapbox Icon-Image Dynamic Symbol (icon) Loading with Sprite

I am trying to do something I feel is very simple, yet seems that I am clearly misunderstanding a crucial piece of the mapbox addlayer feature.
The Goal
Create dynamically identified icons, based on a features data value (e.g. geojson feature data vale title: "walmart"). Essentially just adding dynamic store icons from the sprite image when those locations are queried via tilequery. picture representation here
The problem
I keep getting an error when trying to use the sprite values from the style. Error: util.js:349 Image "airport-11" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.
I see tons of resources talking about sprites, but none discuss how to exactly implement them in this fashion. I have even tried querying the sprite and then adding the values using dot notation to access sprite values. This gives an error of "undefined" and invalid value.
Example code:
map.addLayer({
id: "tilequery-points",
type: "symbol",
source: "tilequery", // Set the layer source
layout: {
"icon-image": [
"match",
["get", "title"],
["HEB"],
"H-E-B_logo",
["Pilot Flying j"],
sprite.Pilot_Travel_Centers_logo,
// "Pilot_Travel_Centers_logo",
["Dollar General"],
"Dollar_General_logo",
["Cumberland Farms Corp"],
"Cumberland_Farms_logo (1)",
["CEFCO"],
"CEFCO-convenience-stores-Logo_510px",
["BJs Wholesale Inc"],
The Question
How do I access the sprite values and not get an error?!!!
Thanks for the help! I Wouldn't ask if I didn't need it!
UPDATE
I have figured out that to use sprite images inside of any layer, the images will automatically be available if you have them in your Mapbox studio sprite image collection. The confusion was that previously, I was not able to use them from link. However, it should work automatically.
Hope it helps!
It's true the documentation about sprites is not super clear. I'll try to summarise (simplifying a bit).
A Mapbox GL style has one sprite. That's a PNG containing all the icons, plus a JSON file specifying what each icon is called (its icon ID), and where it located within the PNG. The sprite is specified by giving a URL as the sprite property: https://docs.mapbox.com/mapbox-gl-js/style-spec/sprite/
You can also add images to the sprite dynamically after the map loads, with map.loadImage and map.addImage, specifying the icon ID.
To display an icon, you use that same ID in a symbol layer: "icon-image": "myicon".
You can run into trouble when you try to combine your own icons with those in a Mapbox basemap (which are Maki icons with names like `airport-11').
To combine them, you can do one of these three things:
upload your icons to a style in Mapbox Studio
load your icons dynamically
generate a new sprite sheet offline, using something like mbsprite
I don't know what you meant about "dot notation", but no, that's not the right path.

Can map points be entered in Postgis by clicking on the map in QGIS?

I have a Postgis table of about 200 entries for which I have to enter lat/lon coordinates. I use QGIS to process and display them. Is there a way of clicking at the QGIS map and thereby entering the coordinates into the Postgis table?
I can find the coordinates on the map, copy the coordinates and enter them in the table. But that is a lot of work and it is error prone. I browsed thru all plugins, found the digitizing tools promising but this does not do what I want. I googled this specific question but didn't find a clue.
Is what I want possible at all?
I am rather a noob at gis and qgis so it took me some time before I had the right keywords to search with. And the right keyword for what I want to do apparently is "digitize". What I want is partially possible. Links that helped me are:
https://www.igismap.com/digitization-in-qgis-exploring-tools-for-digitizing/
https://www.qgistutorials.com/en/docs/digitizing_basics.html
https://gis.stackexchange.com/questions/41799/adding-shapefiles-to-postgis-database
The gist of it is:
enable the advance digitizing toolbar: view > toolbars > advanced digitizing toolbar
create a new shapefile layer: layer > create new shapefile layer. Don't forget the correct fields, in my case the name of the location. Also try to remember where you store the file (it will be a shapefile), you later need that to import the shapefile into postgis
enable the edit state of the current layer, enable the type of shape you want to import. In my case they were points
click on each location, a dialog pops up with the attributes you should add
later on you should import the shapefile, you need the third link for that together with your memory of where you stored that #$#%$& file

Online Maps (google, nokia)

Is it possible to highlight a list of countries with a different colors?
I need to display some countries' statistics on the world map.
Now I use an image and fill a region with color (calculated for each country) by country's coordinates. It's a simple solution and it works well. But now I need to specify the countries' name too (and I think it's not the last customization).
There is a polygon solution, but it uses an array of coordinates. I don't think it's a suitable solution to highlight countries's territory.
I haven't found a solution yet. Any suggestions?
Thanks in advance.
Highlighting countries or regions to support statistics is known as Choropleth Mapping
, but unfortunately there usually isn't direct library support for Choropleth maps bundled into an online map API. This means you'll have to create your own framework, but fortunately it is possible to create one - I wrote an example using jQuery + HERE Maps to
answer the question here
Updated WKT solution now available
Access to KML shapes is no longer required, since the Geocoder API now offers an IncludeShapes attribute which returns the shape of a country in WKT format. A WKT parser can be found here.
A simple WKT choropleth example can be found here.
KML Base solution
For any framework you will need to have a file holding the boundaries of the countries or regions you need. The example uses a KML file, but you could also start with polygons if you had them. Country borders are a political minefield, which is the reason I guess most online mapping APIs steer clear of them. As a hint: try starting with something like http://geocommons.com/overlays/119819 and simplify it as much as possible to speed up the rendering- many small wiggles in the coast lines and small outlying islands are unnecessary.
Of course you could also try searching for "create choropleth map" from a search engine of your choice and use an tool to create a static image for your data (potentially at several zoom levels) and then use this as the basis of an map tile overlay. This requires a lot more work up front, but would push all the calculations server side and hence be faster to display.
Working example can be found on GitHub here
You could put the country's name into the image. It's not that difficult to place text into an image. The only tricky bit is if you are using tiles, you need to deal with names that cross tile boundaries by drawing the name once for each tile.

How to manage markers and variables in leaflet

I'm trying out the leafletjs.com library which i think is very nice for mobile application, but i'm in doubt how to approach it.
I'm trying to make a realtime map where markers represents the position of each logged on user.
If the user moves, the users marker should move accordingly.
I'm a bit in doubt, how to do this in leaflet. My problem is simply how to make a lot of markers the right way, so i can later pick and move them.
First i need to add each marker to a layergroup, and add that layergroup to the map, right?
But later, how do i programmicaly pick one specific marker and update its position?
Do i need to use any plugins or is leaflet in it self all i need?
Thomas
No, you don't need to add markers to a layergroup, nor do you need any plugins. To add a marker to the map you can simply do:
var marker = L.marker([50.5, 30.5]);
marker.addTo(map);
If you need to move the marker programatically you can use setLatLng:
marker.setLatLng([40.5, 40.5]);
How you decide to map users to markers is really up to you. A simple solution could be to use an object where keys are userId's (or some other user identifier) and values are markers:
var users = {
11: L.marker([35.5, 15.5]),
15: L.marker([40.5, 20.5]),
17: L.marker([45.5, 25.5])
}
Have you read the Leaflet documentation?
http://leafletjs.com/reference.html
You can also read this short example on using Leaflet on mobile devices:
http://leafletjs.com/examples/mobile.html
Check out these resources:
Leaflet on Mobile
Real-Time Geolocation Service with Node.js
Google Search: leaflet.js tutorial geolocation

click marker into a map instead of fill out the addressfield

I am using the openlayers addressfield, geocode and geofield modules in Drupal7 to let the users create content with relevant geodata. But for some content there is no streetname available. So i would like to have a prezoomed maparea where the user can click in and flag the right position, instead of typing in the addressfield.
I tried to use the geofield with the "Openlayers Widget Map", but it's not exactly what i need.
Does anybody know how to use the modules for that?
Is there a tutorial for that?
Kind Regards
Michi
thx for answering!
Yes, in theory it works. I tried it befor with the geofield module.
And yes, i could see the map in the contenttype form while creating a node.
But i havn't found a way to prezoom the map into relevant places (or use the geolocate bevahior for that) or change the marker style for that geofield map. The only mapstyle i can choose in the contenttype field setting is the "geofield widget map". So i have no choice to use an individual prezoomed map with own marker styles.
Changing the "OpenLayers Default Map" in the openlayers settings makes no difference.
So maybe i've overlooked something to customize the geofield, but the module has no configuration link. So without some more configurations, the module is not practicable for users to flag a node with geofield.
Any other ideas or informations?
You can do this with the Geofield module: http://drupal.org/project/geofield
When you enable that module, you can add a Geofield field on your content type and set the widget to be an 'Openlayers Map'... the geofield field lets you input geographic information in a variety of ways, but just clicking on a map is one way. It probably uses the default zoom and center you have saved for your Openlayers map.
Try that out and let us know if it worked!!
Here are the options for entering in address information via Geofield:

Resources