Forum

[SOLVED] OSM Open S...
 
Notifications
Clear all

[SOLVED] OSM Open Street Maps - map not showing

17 Posts
3 Users
0 Likes
1,158 Views
Zero-Labs
(@zero-labs)
Posts: 82
Trusted Member
Topic starter
 

Got, activated and inserted my MapQuest API key into index.php per instructions. The map place holder is inserted on the item page however, the map area is empty. There's really nothing else to configure that I can find. Google Maps Plus plugin sort of works but I'm not going to create a billing account to make it fully functional. Not sure what I'm doing wrong. I've tried with and without a callback URL in the MapQuest API key manager. phpinfo() reports allow_url_fopen is in fact On. Ideas anyone?

 
Posted : 30/01/2020 4:20 am
Zero-Labs
(@zero-labs)
Posts: 82
Trusted Member
Topic starter
 

So, the version I got initially from the Navjottomer github library is 1.0.3. Turns out there's a newer version 1.0.4 available here https://github.com/dev-101/open_street_maps . It includes a debug feature which I activated. It produces the following data in the footer. As you will see, it looks like MapQuest is parsing the address to lat/lon coordinates of a sample listing. The only thing that's not happening is the image is not populating the place holder on the item page. Seriously, I'm sure it's something stupid I'm doing. Any help appreciated.

SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [timestamp] => Thu, 30 Jan 20 15:37:11 -0700
            [attribution] => Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright
            [querystring] => 541 Albany Turnpike,Collinsville,Connecticut,United States
            [polygon] => false
            [exclude_place_ids] => 93016354
            [more_url] => http://ip-10-98-178-30.mq-us-east-1.ec2.aolcloud.net/nominatim/search.php?q=541+Albany+Turnpike%2CCollinsville%2CConnecticut%2CUnited+States&exclude_place_ids=93016354&addressdetails=1&format=xml
        )

    [place] => SimpleXMLElement Object
        (
            [@attributes] => Array
                (
                    [place_id] => 93016354
                    [osm_type] => way
                    [osm_id] => 94402921
                    [place_rank] => 26
                    [boundingbox] => 41.8360791,41.8361537,-72.9296451,-72.929555
                    [lat] => 41.8361537
                    [lon] => -72.9296451
                    [display_name] => Albany Turnpike, Silvermine Acres, Town of Canton, Hartford County, Connecticut, 06022, United States of America
                    [class] => highway
                    [type] => primary
                    [importance] => 0.535
                )

            [road] => Albany Turnpike
            [hamlet] => Silvermine Acres
            [town] => Town of Canton
            [county] => Hartford County
            [state] => Connecticut
            [postcode] => 06022
            [country] => United States of America
            [country_code] => us
        )

)

 
Posted : 31/01/2020 12:51 am
Defected
(@dftd)
Posts: 614
Honorable Member Admin
 

Uhh, any errors in console (F12)?

Available for custom Osclass development. www.defected.dev

 
Posted : 31/01/2020 4:43 pm
Zero-Labs
(@zero-labs)
Posts: 82
Trusted Member
Topic starter
 

Good call. I normally use FF but I'm at work right now using Chrome. End result is the same regardless.

Of course being just a hack I have no idea how to take this information and create a fix for it.

I also reached out to dev101 (Darko) via his web contact form at osclass.work yesterday since he is the author. This was his reply today...

Hi, sorry, I no longer support that plugin. I suggest you investigate yout theme's css and javascript issues for potential source of the problem (e.g. try different themes) and disable other plugins, particularly map related oned. Gook luck!

Yeah. Thanks a lot. Didn't bother to reply I've already done all those things. I guess he's leaving us stranded to figure it out on our own.

 
Posted : 31/01/2020 7:07 pm
Zero-Labs
(@zero-labs)
Posts: 82
Trusted Member
Topic starter
 

In Firefox console, the error is

The script from “ https://mylocalgrowers.com/oc-content/plugins/open_street_maps/js/leaflet.js”  was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.  index.php
Loading failed for the <script> with source “ https://mylocalgrowers.com/oc-content/plugins/open_street_maps/js/leaflet.js”. index.php:45:1
ReferenceError: L is not defined  index.php:161:11

followed by a whole bunch of these warnings repeated over and over which I get whether or not the OSM plugin is enabled...

Content Security Policy: Ignoring “'unsafe-inline'” within script-src: ‘strict-dynamic’ specified
Content Security Policy: Ignoring “https:” within script-src: ‘strict-dynamic’ specified
Content Security Policy: Ignoring “http:” within script-src: ‘strict-dynamic’ specified

In the page debugger the rendered page code is

45 <script type="text/javascript" src="" https://mylocalgrowers.com/oc-content/plugins/open_street_maps/js/leaflet.js"></script> [/code"]

157        <div id="map" style="height:300px; width:100%;"></div>
158
159
160 <script type="text/javascript">
161 var map = new L.Map('map', {center: new L.LatLng(40, -35), zoom: 2});
162 var osm = new L.TileLayer(' https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png ', {attribution: '&copy; <a href="" https://osm.org/copyright">OpenStreetMap</a> ;" contributors' });
163 map.addLayer(osm);
164 L.marker([40, -35]).addTo(map).bindPopup("location");
165 </script>
 
Posted : 01/02/2020 3:20 pm
Defected
(@dftd)
Posts: 614
Honorable Member Admin
 

Rename plugin folder from "open_street_maps-master" to "open_street_maps". It's a problem that often happens when downloading plugins from GitHub.

Available for custom Osclass development. www.defected.dev

 
Posted : 01/02/2020 3:28 pm
Zero-Labs
(@zero-labs)
Posts: 82
Trusted Member
Topic starter
 

HOT DAMN!!!  See?  I knew it was something stupid.  That's quite the PITA.  Explains a LOT of problems I had trying to install other plugins.

Only thing I have to do now is resave all the listings else everyone is in the mid Atlantic Ocean!

Thanks so much! Might buy you another beer or two!

P.S. Is there a way to refresh all the geo data in one operation?

 
Posted : 01/02/2020 5:04 pm
Defected
(@dftd)
Posts: 614
Honorable Member Admin
 

You're welcome. 🙂

P.S. Is there a way to refresh all the geo data in one operation?

Maybe running something like this would do it. But depending on the number of items you may be limited with the API.


<?php
while(osc_has_items()) {
    osm_insert_geo_location(array('pk_i_id' => osc_item_id()));
}
?>

Available for custom Osclass development. www.defected.dev

 
Posted : 01/02/2020 6:31 pm
Zero-Labs
(@zero-labs)
Posts: 82
Trusted Member
Topic starter
 

Meh. I only had 21 listings that I manually entered so far. Took me all of 10 minutes to run through them one at a time in Manage Listings and click "Update listing" for each one. Going forward they should all be geo tagged when adding new listings. I do wonder if the Ad Import plugin will do it too? I plan to tinker with it later this weekend.

 
Posted : 01/02/2020 6:45 pm
Defected
(@dftd)
Posts: 614
Honorable Member Admin
 

Meh. I only had 21 listings that I manually entered so far. Took me all of 10 minutes to run through them one at a time in Manage Listings and click "Update listing" for each one. Going forward they should all be geo tagged when adding new listings. I do wonder if the Ad Import plugin will do it too? I plan to tinker with it later this weekend.

It's should do it, ads are imported with ItemActions class where the necessary hooks (for custom fields, plugins) are run.

Available for custom Osclass development. www.defected.dev

 
Posted : 01/02/2020 6:54 pm
Zero-Labs
(@zero-labs)
Posts: 82
Trusted Member
Topic starter
 

Yes, it does do it, albeit very poorly. By that I mean 80% of the listings I've tested by importing are pegged on the map in waters somewhere off the coast of Nigeria! This despite the fact that the addresses appear to be properly formatted. I've also found a high percentage of addresses that do the same even if entered manually.

When I researched the poor API performance issue with MapQuest, what I found was some replies from moderators who said if their API cannot find an exact address it returns the next closest coordinates it can find. I replied "NOT true!"

However, the overall performance is SO BAD that I'm forced to wonder if the OSM plugin isn't sending poorly formatted text to the MapQuest API? I'm a little gun shy to pull the trigger on using the ad importer to import close to 8,800 ads that might otherwise get a better location fix if the OSM plugin is at fault and can be fixed.

 
Posted : 04/02/2020 11:37 pm
Zero-Labs
(@zero-labs)
Posts: 82
Trusted Member
Topic starter
 

After running the OSM debugger and studying the output, I've decided this is entirely a MapQuest problem. It is NOT TRUE that the API will fall back to a more general address in the same area if it cannot find a specific street address.

Example:
409 W Green St, Athens, Alabama. MapQuest returns 0,0. (This is a valid address)
W Green St, Athens, Alabama. MapQuest returns 0,0.
Green St, Athens, Alabama. MapQuest returns 34.804549,-86.971170.
Athens, Alabama. MapQuest returns 34.804549,-86.971170.
BUT... 409 Green St W, Athens, Alabama. MapQuest returns 34.801025,-86.974119 (The true address coordinates)

So if MapQuest can't find a precise street address, the city and state do not exist. Isn't that just special?

 
Posted : 05/02/2020 1:39 am
Zero-Labs
(@zero-labs)
Posts: 82
Trusted Member
Topic starter
 

And yet...

I can go to the MapQuest developer portal, enter the address ne nearly all formats and it works. {sigh}

I guess I'm back to troubleshooting the OSM plugin formatting.

 
Posted : 05/02/2020 3:19 am
Zero-Labs
(@zero-labs)
Posts: 82
Trusted Member
Topic starter
 

So the FINAL verdict (yes really) is this is definitely MapQuest providing substandard service to open API users. Using the example request given at https://developer.mapquest.com/documentation/open/nominatim-search/search/ and filling in the blanks with my own API key and example addresses...

This one works.

 http://open.mapquestapi.com/nominatim/v1/search.php?key=MYKEY&format=json&q=409  Green St W, Athens, Alabama&addressdetails=1&limit=1

This one does not work.

 http://open.mapquestapi.com/nominatim/v1/search.php?key=MYKEY&format=json&q=409  W Green St, Athens, Alabama&addressdetails=1&limit=1

But plug in those same address using the developer website test form and it works in all its forms. Translation: I was not incorrect to rip them a new one for providing substandard service. No amount of plugin changes will fix it. If you're going to enter a street address, is must match exactly as they have it stored in their own database (else OMIT the address altogether) or you get nothing for results. Period, the end.

Bottom line is no map is better than a map that only works <1/4 of the time. Not worth the aggravation. If my users want a map on their ad they can pull one up themselves with google maps, clip it and upload to one of the 5 images I allow.

 
Posted : 06/02/2020 1:26 am
Zero-Labs
(@zero-labs)
Posts: 82
Trusted Member
Topic starter
 
Posted by: @dftd

You're welcome. 🙂

P.S. Is there a way to refresh all the geo data in one operation?

Maybe running something like this would do it. But depending on the number of items you may be limited with the API.


while(osc_has_items()) {
    osm_insert_geo_location(array('pk_i_id' => osc_item_id()));
}
?>

I'm kinda desperate to get something that automatically refreshes the lat/lon. Would item.php be the place to insert this code?

Edit: Inserting into item.php did nothing at all.

This post was modified 1 year ago by Zero-Labs
 
Posted : 19/10/2021 6:38 pm
Page 1 / 2
Share: