Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

django-gmapi-new

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

django-gmapi-new

A Google Maps API implementation for Django

  • 1.0.1.1
  • PyPI
  • Socket score

Maintainers
1

========================================================= Django Google Maps API v3 and Static Maps API helper app.

This app allows you to define Google Map and Marker objects in Python.

These objects are designed to be serialized to JSON and parsed by the included jQuery plugin which converts them to actual Google Map and Marker instances.

They can also be serialized to strings which produces a Static Maps url.

This way you can easily use unobtrusive javascript techniques along with maps.

This project is being developed as one piece of a larger project I'm working on. So functionality will be added as I need it. In particular, the jQuery plugin will probably see some added functionality.

Version 3 of the Google Geocoding Web service is also implemented to further enable an unobtrusive javascript approach.

New: Events and Info Windows You can now add info windows maps and markers and add event listeners. Adding to the example below, in your views.py (right after "gmap = maps.Map...") add:

marker = maps.Marker(opts = {
    'map': gmap,
    'position': maps.LatLng(38, -97),
})
maps.event.addListener(marker, 'mouseover', 'myobj.markerOver')
maps.event.addListener(marker, 'mouseout', 'myobj.markerOut')
info = maps.InfoWindow({
    'content': 'Hello!',
    'disableAutoPan': True
})
info.open(gmap, marker)

Then, on your page:

That's it!

Example:

"""views.py""" from django import forms from django.shortcuts import render_to_response from gmapi import maps from gmapi.forms.widgets import GoogleMap

class MapForm(forms.Form): map = forms.Field(widget=GoogleMap(attrs={'width':510, 'height':510}))

def index(request): gmap = maps.Map(opts = { 'center': maps.LatLng(38, -97), 'mapTypeId': maps.MapTypeId.ROADMAP, 'zoom': 3, 'mapTypeControlOptions': { 'style': maps.MapTypeControlStyle.DROPDOWN_MENU }, }) context = {'form': MapForm(initial={'map': gmap})} return render_to_response('index.html', context)

"""urls.py""" from django.conf.urls.defaults import *

urlpatterns = patterns('', (r'^$', 'myapp.views.index'), )

"""settings.py""" INSTALLED_APPS = ( ... 'gmapi', ... )

Then in your template put this somewhere:

{{ form.map }} {{ form.media.js }}

This will result in html like:

Google Map

Your map will be displayed as an image, and once/if javascript loads, it will be converted to a javascript map.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc