Discussion:
[mapguide-users] Slow Openstreetmap
Kajar
2018-06-20 19:23:33 UTC
Permalink
Hi!

I have issue related to very slow Openstreetmap loading.
I'm using MGOS 3.1.1, WinServer 2016, Apache webserver.
It happened after Google Maps stopped working and I was pushed to use
Openstreetmap(Mapnik) as default background. When I switch to use OpenStreet
Map (TransportMap) then there is no problem with slow loading tiles, only
Mapnik doesnt want to load as it should. I also disabled all Google Maps
options from web layout.
Chrome developer tool show me errors:

[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated
because of its detrimental effects to the end user's experience. For more
help, check https://xhr.spec.whatwg.org/.
b @ fusionSF.js:1686
(anonymous) @ fusionSF.js:1759
(anonymous) @ fusionSF.js:1726

A parser-blocking, cross site (i.e. different eTLD+1) script,
http://www.openstreetmap.org/openlayers/OpenStreetMap.js, is invoked via
document.write. The network request for this script MAY be blocked by the
browser in this or a future page load due to poor network connectivity. If
blocked in this page load, it will be confirmed in a subsequent console
message. See https://www.chromestatus.com/feature/5718547946799104 for more
details.

A parser-blocking, cross site (i.e. different eTLD+1) script,
http://maps.google.com/maps/api/js?v=3.3&sensor=true&client=, is invoked via
document.write. The network request for this script MAY be blocked by the
browser in this or a future page load due to poor network connectivity. If
blocked in this page load, it will be confirmed in a subsequent console
message. See https://www.chromestatus.com/feature/5718547946799104 for more
details.

fusionSF.js:1673 A parser-blocking, cross site (i.e. different eTLD+1)
script, http://maps.stamen.com/js/tile.stamen.js?v1.3.0, is invoked via
document.write. The network request for this script MAY be blocked by the
browser in this or a future page load due to poor network connectivity. If
blocked in this page load, it will be confirmed in a subsequent console
message. See https://www.chromestatus.com/feature/5718547946799104 for more
details.

Does anyone experiencing similar problems?
Does someone have an idea how to fix this map loading time issue.

Kajar






--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
RenoSun
2018-06-20 22:02:02 UTC
Permalink
Hi Kajar,

I think that I was facing some similar issue before too.

I modified the following codes, but I am using AIMS 2017...not exactly MG
3.1.1.

You may also want to check out the following:

1.Hotfix for Bing Map V8

https://knowledge.autodesk.com/support/infrastructure-map-server/troubleshooting/caas/downloads/content/autodesk-infrastructure-map-server-2017-bing-maps-hotfix.html

http://osgeo-org.1560.x6.nabble.com/New-builds-of-Fusion-to-support-new-Bing-Maps-td5326055.html

2.

fusionSF.js
...
var addElement = function (element) {
if (!element) {
return;
}
var src = element.textContent;

// For IE Browser
if (!src) {
src = element.text;
}

if (src !=
"http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2") {
if (location.protocol == 'https:') {
if (src ==
"http://maps.stamen.com/js/tile.stamen.js?v1.3.0") {
src =
"https://stamen-maps.a.ssl.fastly.net/js/tile.stamen.js";
document.writeln('<script src="' + src +
'"><\/script>');
}
else{
document.writeln('<script src="' + src.replace('http',
'https') + '"><\/script>');
}
}
else
{
document.writeln('<script src="' + src + '"><\/script>');
}
}
}
...

3.
http://osgeo-org.1560.x6.nabble.com/MapGuide-AIMS-OSM-TransportMap-and-CycleMap-API-Key-Required-td5332053.html

...
switch (this.layerType) {
case 'Google':
switch (this.mapTag.layerOptions.type) { //Google layer
types are actual objects
case 'G_PHYSICAL_MAP': //defined by gmap,
not a string
case 'TERRAIN':
this.mapTag.layerOptions.type =
google.maps.MapTypeId.TERRAIN;
break;
case 'G_HYBRID_MAP':
case 'HYBRID':
this.mapTag.layerOptions.type =
google.maps.MapTypeId.HYBRID;
break;
case 'G_SATELLITE_MAP':
case 'SATELLITE':
this.mapTag.layerOptions.type =
google.maps.MapTypeId.SATELLITE;
break;
case 'G_NORMAL_MAP':
case 'ROADMAP':
this.mapTag.layerOptions.type =
google.maps.MapTypeId.ROADMAP;
default:
// For the re-loaded Google layers
if (this.mapTag.layerOptions.type ==
google.maps.MapTypeId.TERRAIN)
this.mapTag.layerOptions.type =
google.maps.MapTypeId.TERRAIN;
else if (this.mapTag.layerOptions.type ==
google.maps.MapTypeId.HYBRID)
this.mapTag.layerOptions.type =
google.maps.MapTypeId.HYBRID;
else if (this.mapTag.layerOptions.type ==
google.maps.MapTypeId.SATELLITE)
this.mapTag.layerOptions.type =
google.maps.MapTypeId.SATELLITE;
else
this.mapTag.layerOptions.type =
google.maps.MapTypeId.ROADMAP;
break;
}
break;
case 'VirtualEarth':
this.mapTag.layerOptions.animationEnabled = false;
switch (this.mapTag.layerOptions.type) { //VE layer types
are enumerated values
case 'Aerial': //defined in VEMapStyle from
the VE api
case 'a':
this.mapTag.layerOptions.type = 'Aerial';
break;
case 'AerialWithLabels':
this.mapTag.layerOptions.type = 'AerialWithLabels';
break;
default:
this.mapTag.layerOptions.type = 'Road';
break;
}
this.oLayerOL = new OpenLayers.Layer.Bing({
key: Fusion.bingMapKey,
type: this.mapTag.layerOptions.type
});
break;
case 'Yahoo':
switch (this.mapTag.layerOptions.type) { //Yahoo is
similar to google
case 'YAHOO_MAP_SAT': //defined by YMap,
not a string
case 'YAHOO_SAT':
this.mapTag.layerOptions.type = YAHOO_MAP_SAT;
break;
case 'YAHOO_MAP_HYB':
case 'YAHOO_HYB':
this.mapTag.layerOptions.type = YAHOO_MAP_HYB;
break;
case 'YAHOO_MAP_REG':
case "YAHOO_REG":
default:
this.mapTag.layerOptions.type = YAHOO_MAP_REG;
break;
}
break;
case 'OpenStreetMap':
case 'OSM':
if (this.mapTag.layerOptions.type) {
this.mapTag.layerOptions.type =
this.mapTag.layerOptions.type;
}
else {
this.mapTag.layerOptions.type = 'Mapnik';
}
break;
case 'Stamen':
this.oLayerOL = new
OpenLayers.Layer[this.layerType](this.mapTag.layerOptions.type);
break;
case 'XYZ':
this.oLayerOL = new OpenLayers.Layer[this.layerType](
this.getMapName(),
this.sMapResourceId,
this.mapTag.layerOptions);
break;
default:
this.oLayerOL = new OpenLayers.Layer[this.layerType](
this.getMapName(),
this.sMapResourceId,
this.mapTag.layerParams,
this.mapTag.layerOptions);

break;
}

if (!this.oLayerOL) {
if (this.layerType == 'OpenStreetMap' || this.layerType ==
'OSM') {
//Test OSM sub-type before falling back to
OpenLayers.Layer.OSM
//if (typeof
(OpenLayers.Layer.OSM[this.mapTag.layerOptions.type]) != 'undefined') {
//this.oLayerOL = new
OpenLayers.Layer.OSM[this.mapTag.layerOptions.type](this.getMapName(), null,
this.mapTag.layerOptions);
//console.log('test1: ' +
this.mapTag.extension.Options[0].type[0]);
//} else {
//console.log("mapTagExtensionOptionType " +
this.mapTag.extension.Options[0].type[0]);
if (this.mapTag.extension.Options[0].type[0] == "Mapnik") {
this.oLayerOL = new
OpenLayers.Layer.OSM[this.mapTag.layerOptions.type](this.getMapName(), null,
this.mapTag.layerOptions);
}
else if (this.mapTag.extension.Options[0].type[0] ==
"CycleMap") {
//this.oLayerOL = new
OpenLayers.Layer.OSM(this.getMapName(), null, this.mapTag.layerOptions);
this.oLayerOL = new OpenLayers.Layer.OSM("***@h",
["Loading Image...
"Loading Image...
"Loading Image...
}
else if (this.mapTag.extension.Options[0].type[0] ==
"TransportMap") {
this.oLayerOL = new OpenLayers.Layer.OSM("***@h",
["Loading Image...
"Loading Image...
"Loading Image...
}
else if (this.mapTag.extension.Options[0].type[0] ==
"Outdoors") {
this.oLayerOL = new OpenLayers.Layer.OSM("***@h",
["Loading Image...
"Loading Image...
"Loading Image...
}
}
else {
this.oLayerOL = new
OpenLayers.Layer[this.layerType](this.getMapName(),
this.mapTag.layerOptions);
//fractionalZoom not permitted with tiled base layers
regardless
this.mapWidget.fractionalZoom = false;
this.mapWidget.oMapOL.setOptions({ fractionalZoom: false });
}
}

this.oLayerOL.events.register("loadstart", this, this.loadStart);
this.oLayerOL.events.register("loadend", this, this.loadEnd);
this.oLayerOL.events.register("loadcancel", this, this.loadEnd);
...

I hope any of these may help you.

Reno



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
RenoSun
2018-06-25 15:43:04 UTC
Permalink
Check this out too...
A Parser-blocking, cross-origin script is invoked via document.write - how
to circumvent it?
<https://stackoverflow.com/questions/39610829/a-parser-blocking-cross-origin-script-is-invoked-via-document-write-how-to-ci/41765273>



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
Kajar
2018-07-25 08:06:21 UTC
Permalink
It seems that sometimes Openstreet service is just really slow or not
working.
Does someone have created own OSM tile server and configured Mapguide to use
it?

Kajar



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
Jackie Ng
2018-07-25 09:13:17 UTC
Permalink
If you expect heavy traffic, OSM wants (expects) you to set up your own tile
server.

Now in terms of getting it to use your own OSM tile server, it should be
simple. OSM/Stamen are just XYZ tile layers with a well-known domain name.
So pointing to your own OSM tile server would just be a case of changing
tile.openstreetmap.org to the hostname of your custom OSM tile server.

Whether Fusion currently makes it easy for you to do this out of the box,
I'd have to investigate further.

- Jackie



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
Kajar
2018-07-26 09:35:48 UTC
Permalink
Its good to know where I need to define new openstreet tile server host name,
which replace the old one.

Kajar



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
Jackie Ng
2018-07-26 16:51:01 UTC
Permalink
Current Fusion doesn't do this. I'm making changes to let you do this. It
will work something like this:

Where your OSM layer fragment in the Application Definition looks like this:

<Map>
<Type>OpenStreetMap</Type>
<SingleTile>true</SingleTile>
<Extension>
<Options>
<name>Open Street Map</name>
<type>Mapnik</type>
</Options>
</Extension>
</Map>

The changes I am making will allow you to do something like this:

<Map>
<Type>OpenStreetMap</Type>
<SingleTile>true</SingleTile>
<Extension>
<Options>
<name>Open Street Map</name>
<type>Mapnik</type>
<urls>http://myalternativeosmtileserver1/${z}/${y}/${x}</urls>
<urls>http://myalternativeosmtileserver2/${z}/${y}/${x}</urls>
</Options>
</Extension>
</Map>

And the OSM layer will use the specified tile source URLs instead of the
default.

This will work for CycleMap and TransportMap as well, so that if the API key
watermarks annoy you, you can use this same mechanism to specify
alternatives like (http://www.thunderforest.com/docs/apikeys/)

And along the way, I'm also cleaning up the way Fusion is initialized. We
don't need to append script tags for Bing/OSM/Stamen (only for Google Maps).
There's layer types already present in OpenLayers to use such external
layers, the scripts we're trying to fetch are not that complicated and can
be easily baked into Fusion itself.

- Jackie



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
Kajar
2018-07-27 07:00:08 UTC
Permalink
Thanks Jackie, this is great news.



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
RenoSun
2018-07-27 18:20:18 UTC
Permalink
Yahoo! This will be an awesome feature!



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
Jackie Ng
2018-07-25 09:00:47 UTC
Permalink
I think this is because of Fusion trying to append script tags (on the
client-side) to the template page from the ApplicationDefinitions (for
Google/Bing/OSM/Stamen) if it finds them and now its ringing security alarm
bells for modern browsers because of this.

Workaround? The simplest solution would be to rework the template entry
point so they all go through a server-side PHP script first.

ie. Instead of

servername/mapguide/fusion/templates/mapguide/slate.html?ApplicatonDefinition=...

We'd run

servername/mapguide/fusion/template.php?name=slate&ApplicationDefinition=...

And then within template.php, we'd output the HTML for the appropriate
template as indicated by {name} and be able to safely append the required
script tags if we find them in the {ApplicationDefinition}

- Jackie




--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
Loading...