New StackOverflow Question: MapBox/Open Layers map rendering tiles incorrectly

4 views
Skip to first unread message

stacko...@mg.bodar.com

unread,
Mar 7, 2017, 5:10:34 AM3/7/17
to total...@googlegroups.com

MapBox/Open Layers map rendering tiles incorrectly

Asked by purplelionastronaut on 2017-02-16T13:51:03Z

Reply on StackOverflow

enter image description here

As per the image above, I am trying to render a map in OpenLayers/MapBox with the following code:

var map = new ol.Map({
    layers: [
      new ol.layer.Tile({
        source: new ol.source.XYZ({
        url: 'https://api.mapbox.com/styles/v1/mapbox/streets-v9/tiles/512/{z}/{y}/{x}?access_token=<the access token goes here>'
        })
      })
    ],
    target: 'map',
    controls: ol.control.defaults({
      attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
        collapsible: false
      })
    }),
    view: new ol.View({
      center: [0, 0],
      zoom: 2
    })
  });

HTML:

{% extends "layout.html" %}

{% block head %}
<link rel="stylesheet" href="https://openlayers.org/en/v4.0.1/css/ol.css" type="text/css">
<link href='http://mapbox.com/base/latest/base.css' rel='stylesheet'/>
{% endblock %}

{% block body %}
<main id="content">
<div id="map" class="map" tabindex="0"></div>
</main>
<script src="https://openlayers.org/en/v4.0.1/build/ol.js"></script>
<script src="{{ url_for('static', filename='js/search/map.js')></script>

{% endblock %}

Obviously the map is not rendering correctly. Anyone come across this before?

Reply on StackOverflow
Reply all
Reply to author
Forward
0 new messages