1

I'm trying to implement creating custom geographic object by GeoDjango. In model I have this field.

mpoly = models.MultiPolygonField()

Then I create form

 from django.contrib.gis import forms as geoforms
 from world.models import Country

 class CountryForm(geoforms.ModelForm):
    class Meta:
        model = Country
        widgets = {
            'mpoly': geoforms.OSMWidget(attrs={'map_width': 800, 'map_height': 500}),
        }

and rendered it by

<head>{{ form.media }}</head>
<body>
   <form>
      {{form}}
      <button class="btn btn-primary" type="submit">Save</button>
   </form>
</body>

Full page code is here

After drawing polygon on map I get error in MapWidget.searializeFeatures function.

Uncaught TypeError: a.Y is not a function
at bp (https://cdnjs.cloudflare.com/ajax/libs/ol3/3.20.1/ol.js:459:803)
at Zo.k.Te (https://cdnjs.cloudflare.com/ajax/libs/ol3/3.20.1/ol.js:464:27)
at Zo.k.od (https://cdnjs.cloudflare.com/ajax/libs/ol3/3.20.1/ol.js:431:47)
at MapWidget.serializeFeatures (http://localhost:8000/gstatic/gis/js/OLMapWidget.js:227:69)
at D.<anonymous> (http://localhost:8000/gstatic/gis/js/OLMapWidget.js:89:22)
at D.b (https://openlayers.org/en/v4.0.1/build/ol.js:41:394)
at Dc.b (https://openlayers.org/en/v4.0.1/build/ol.js:44:213)
at D.k.Be (https://openlayers.org/en/v4.0.1/build/ol.js:47:617)
at D.k.push (https://openlayers.org/en/v4.0.1/build/ol.js:48:41)
at Qt.k.Nd (https://openlayers.org/en/v4.0.1/build/ol.js:634:301)

I can't find anything meaningful about this error.

What is the reason for this error, and how can I fix it?

0

I don't think this has anything to do with GeoJSON, or anything spatial. Simply as a redflag,

Uncaught TypeError: a.Y is not a function
at bp (https://cdnjs.cloudflare.com/ajax/libs/ol3/3.20.1/ol.js:459:803)
[...]
at Qt.k.Nd (https://openlayers.org/en/v4.0.1/build/ol.js:634:301)

That means you're running v4.0.1, and v3.20.1. That seems likely to a cause a problem. There are major differences.

  1. I would think you would need to work to remove 3.20.1. See what's including it and nuke that include statement.
  2. file a bug if you're not including it to upgrade to v.x You probably don't want two versions of a massive library like openlayers in your site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.