question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Working with dynamic canvas

See original GitHub issue

I’ve an application that shows one map for each product throught controller. So, I’m trying to set canvas_map dinamically and I did something like that in my template called product-map.html:

<ion-view view-title="MAP">
	<ion-content>  
		<div style="width:100%;height:400px;" ng-attr-id="{{'canvas_map_'+product.id}}"></div>
		<button ng-attr-id="{{'button_'+product.id}}">Dive in map</button>
	</ion-content>
</ion-view>

Besides, I’m trying to call cordova-plugin-googlemaps like that:

.controller('ProductCtrl', function ($scope, $rootScope, $location, $stateParams, $http, $ionicModal, resultProducts) {

	$scope.product = resultProducts;

	var map;
	document.addEventListener("deviceready", function () {
		var div = document.getElementById("map_canvas_" + resultProducts.id);

		// Initialize the map view
		map = plugin.google.maps.Map.getMap(div);

		// Wait until the map is ready status.
		map.addEventListener(plugin.google.maps.event.MAP_READY, onMapReady);
	}, false);

	function onMapReady() {
		var button = document.getElementById("button_" + resultProducts.id);
		button.addEventListener("click", onBtnClicked, false);
	}

	function onBtnClicked() {
		map.showDialog();
	}
})

For some reason this is not working… Please, somebody can help me with a workaround?

I’m submitting a … (check one with “x”) [x] question [ ] any problem or bug report [ ] feature request

If you choose ‘problem or bug report’, please select OS: (check one with “x”) [ ] Android [ ] iOS

cordova information: (run $> cordova plugin list)

insert the output from the command here

If you use @ionic-native/google-maps, please tell the package.json (only @ionic-native/core and @ionic-native/google-maps are fine mostly)

Current behavior:

Expected behavior:

Screen capture or video record:

Related code, data or error log (please format your code or data):

The person who share your project files on Github (or other git repository) is in faster lane than other people.
Please share your project files on Github or others(Bitbucket, Gitlabs...etc).
If you don't want to share your project files, please create a demo project, then share it.

Screen captures, and/or native logs(such as Logcat, xcode logs) are appreciate.

Giving much information, you are waiting time is less.
Thank you for your cooperation.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
wf9a5m75commented, Jan 19, 2018

Doubt your code first please.

.controller('PlaceCtrl', function ($scope, $rootScope, $state, resultPlace) {

	// Load place's data in scope's model
	$scope.place = resultPlace;

	// Create Map
	var map;
	document.addEventListener("deviceready", function () {
		var div = document.getElementById("map_canvas_" + resultPlace.id);
  console.log("div", div);  <-- null

		// Initialize the map view
		map = plugin.google.maps.Map.getMap(div);

		// Wait until the map is ready status.
		map.addEventListener(plugin.google.maps.event.MAP_READY, onMapReady);
	}, false);

screen shot 2018-01-18 at 5 27 55 pm

0reactions
brunovinnycommented, Jan 19, 2018

The problem was in my code and I solved it. Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic Graphics Generation: The Canvas | by Jessica Torres
BASIC CANVAS TERMINOLOGY. Context — This is the drawing/rendering context you are required to set for the canvas element before you can begin...
Read more >
Working with dynamic schema data sources in Power Apps ...
Learn about how to work with data sources that use dynamic schema in service calls when working with canvas apps.
Read more >
Dynamic Web Canvas - WorkWithPlus
A new Control named 'Dynamic Web Canvas' was added. This new Control allows end users to make interactions over some images.
Read more >
Excanvas for dynamically created canvas elements
From the documentation: If you have created your canvas element dynamically it will not have the getContext method added to the element. To...
Read more >
Working with Canvas Elements - Lucky Orange
Our dynamic recordings use browser Mutation Events to figure out when html content changes. This allows us to record highly dynamic pages ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found